|
|
@@ -4,19 +4,13 @@ import cn.hutool.core.util.IdUtil;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
-import com.fs.common.utils.uuid.UUID;
|
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.dto.*;
|
|
|
import com.fs.his.enums.DoctorTypeEnum;
|
|
|
import com.fs.his.mapper.*;
|
|
|
-import com.fs.his.param.PrescribeXyImgParam;
|
|
|
import com.fs.his.service.IFsPrescribeDataScrmService;
|
|
|
import com.fs.his.service.IPollingAssignDoctorService;
|
|
|
-import com.fs.his.service.PrescriptionImageService;
|
|
|
import com.fs.his.vo.DoctorSignVO;
|
|
|
-import com.fs.his.vo.FsPrescribeDataScrmImgVO;
|
|
|
-import com.fs.hisStore.domain.FsStoreProductScrm;
|
|
|
-import com.fs.hisStore.mapper.FsStoreProductScrmMapper;
|
|
|
import com.fs.qw.domain.FsCompanyCustomer;
|
|
|
import com.fs.qw.mapper.FsCompanyCustomerMapper;
|
|
|
import com.fs.qw.service.IFsCompanyCustomerService;
|
|
|
@@ -24,14 +18,12 @@ import com.fs.qw.vo.FsPrescribeDataScrmVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.http.util.Asserts;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -46,16 +38,12 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
|
|
|
@Autowired
|
|
|
private FsPrescribeDataScrmMapper fsPrescribeDataScrmMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private PrescribeScrmTaskRecordMapper scrmTaskRecordMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FsCompanyCustomerMapper companyCustomerMapper;
|
|
|
- @Autowired
|
|
|
- private FsPrescribeDataScrmDrugMapper dataScrmDrugMapper;
|
|
|
- @Autowired
|
|
|
- private PrescriptionImageService prescriptionImageService;
|
|
|
- @Autowired
|
|
|
- private FsStoreProductScrmMapper fsStoreProductScrmMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private FsPrescribeDrugDataScrmMapper drugDataScrmMapper;
|
|
|
@@ -72,6 +60,9 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Autowired
|
|
|
private IPollingAssignDoctorService pollingAssignDoctorService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsPrescibeRecordDataScrmMapper fsPrescibeRecordDataScrmMapper;
|
|
|
+
|
|
|
private IFsPrescribeDataScrmService self() {
|
|
|
return applicationContext.getBean(IFsPrescribeDataScrmService.class);
|
|
|
}
|
|
|
@@ -139,6 +130,17 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Override
|
|
|
public List<FsPrescribeDataScrmVO> pendingStorePrescribeList(FsPrescribeDataDrugDoctorQueryDto queryDto) {
|
|
|
List<FsPrescribeDataScrmVO> list = fsPrescribeDataScrmMapper.pendingStorePrescribeList(queryDto);
|
|
|
+ //收集处方id集合
|
|
|
+ Set<Long> prescribeIds = list.stream().map(FsPrescribeDataScrmVO::getPrescribeId).collect(Collectors.toSet());
|
|
|
+ //查询处方药品列表
|
|
|
+ if (CollectionUtils.isEmpty(prescribeIds)){
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<FsPrescribeDrugDataScrm> drugList = drugDataScrmMapper.selectFsPrescribeDataScrmDrugListByPrescribeIds(prescribeIds);
|
|
|
+ //遍历两个集合将相同的处方id进行匹配
|
|
|
+ for (FsPrescribeDataScrmVO vo : list) {
|
|
|
+ vo.setDrugsList(drugList.stream().filter(d -> d.getPrescribeId().equals(vo.getPrescribeId())).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
return CollectionUtils.isEmpty(list) ? Collections.emptyList() : list;
|
|
|
}
|
|
|
|
|
|
@@ -146,28 +148,24 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int doctorRejectScrmPrescribe(FsPrescribeDataDoctorUpdateDto updateDto) {
|
|
|
+ if (getPrescribeIsDocument(updateDto.getPrescribeId())){
|
|
|
+ throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
|
|
|
+ }
|
|
|
// 1. 清除原有基础处方图片
|
|
|
clearPrescriptionImage(updateDto.getPrescribeId());
|
|
|
|
|
|
// 2. 更新处方主记录
|
|
|
FsPrescribeDataScrm updatePrescribe = new FsPrescribeDataScrm();
|
|
|
BeanCopyUtils.copy(updateDto, updatePrescribe);
|
|
|
+ updatePrescribe.setDoctorConfirm(-1);
|
|
|
int updateCount = fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(updatePrescribe);
|
|
|
-
|
|
|
- // 3. 根据医生确认结果进行后续处理
|
|
|
- if (updateDto.getDoctorConfirm() == 1) {
|
|
|
- // 确认开方 → 异步生成医生签名处方图片
|
|
|
- submitPrescribeImageTask(updateDto.getPrescribeId(), 1);
|
|
|
- // 更新用户状态为待审核
|
|
|
- updateCustomerStatus(updateDto.getPrescribeId(), WAIT_AUDIT);
|
|
|
- } else if (updateDto.getDoctorConfirm() == -1) {
|
|
|
- // 拒方
|
|
|
- if (StringUtils.isBlank(updateDto.getAuditReason())) {
|
|
|
- throw new CustomException("拒方原因不能为空");
|
|
|
- }
|
|
|
- // 更新用户状态为已拒方
|
|
|
- updateCustomerStatus(updateDto.getPrescribeId(), REJECT_PRESCRIBE);
|
|
|
+ // 拒方
|
|
|
+ if (StringUtils.isBlank(updateDto.getAuditReason())) {
|
|
|
+ throw new CustomException("拒方原因不能为空");
|
|
|
}
|
|
|
+ // 更新客户信息表状态为已拒方
|
|
|
+ updateCustomerStatus(updateDto.getPrescribeId(), REJECT_PRESCRIBE);
|
|
|
+
|
|
|
return updateCount;
|
|
|
}
|
|
|
|
|
|
@@ -175,16 +173,27 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int drugDoctorExecuteScrmPrescribe(FsPrescribeDataDrugDoctorUpdateDto updateDto) {
|
|
|
+ if (getPrescribeIsDocument(updateDto.getPrescribeId())){
|
|
|
+ throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
|
|
|
+ }
|
|
|
+ FsPrescribeDataScrm prescribeDataScrm = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmByPrescribeId(updateDto.getPrescribeId());
|
|
|
+ if (prescribeDataScrm == null){
|
|
|
+ throw new CustomException("商城处方单不存在");
|
|
|
+ }
|
|
|
+ //生成商城处方单的审核记录
|
|
|
+ FsPrescibeRecordDataScrm record = new FsPrescibeRecordDataScrm();
|
|
|
+ BeanCopyUtils.copy(prescribeDataScrm, record);
|
|
|
+ fsPrescibeRecordDataScrmMapper.insertFsPrescibeRecordDataScrm(record);
|
|
|
if (updateDto.getStatus() == 1) {
|
|
|
- // 审核通过 → 异步生成医生+药师签名处方图片
|
|
|
+ // 审核通过 → 异步生成医生+药师签名处方图片任务
|
|
|
submitPrescribeImageTask(updateDto.getPrescribeId(), 2);
|
|
|
updateCustomerStatus(updateDto.getPrescribeId(), OPEN_PRESCRIBE);
|
|
|
} else if (updateDto.getStatus() == 2) {
|
|
|
// 审核不通过 → 清除处方图片,退回状态
|
|
|
clearPrescriptionImage(updateDto.getPrescribeId());
|
|
|
+ updateDto.setDoctorConfirm(0);//药师审核不通过,处方医生状态回退为"待开方"
|
|
|
updateCustomerStatus(updateDto.getPrescribeId(), IS_PRESCRIBING);
|
|
|
}
|
|
|
-
|
|
|
// 更新处方主记录
|
|
|
FsPrescribeDataScrm updatePrescribe = new FsPrescribeDataScrm();
|
|
|
BeanCopyUtils.copy(updateDto, updatePrescribe);
|
|
|
@@ -231,6 +240,9 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
|
|
|
@Override
|
|
|
public int addDoctorAdvice(BeforePrescribeAddDoctorAdviceDTO addDoctorAdviceDTO) {
|
|
|
+ if (getPrescribeIsDocument(addDoctorAdviceDTO.getPrescribeId())){
|
|
|
+ throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
|
|
|
+ }
|
|
|
//获取处方信息
|
|
|
FsPrescribeDataScrm fsPrescribeDataScrm = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmByPrescribeId(addDoctorAdviceDTO.getPrescribeId());
|
|
|
if (fsPrescribeDataScrm == null) {
|
|
|
@@ -249,6 +261,9 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int updateBasicInfo(FsPrescribeDataBasicInfoDto basicInfoDto) {
|
|
|
+ if (getPrescribeIsDocument(basicInfoDto.getPrescribeId())){
|
|
|
+ throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
|
|
|
+ }
|
|
|
FsPrescribeDataScrm update = new FsPrescribeDataScrm();
|
|
|
update.setPrescribeId(basicInfoDto.getPrescribeId());
|
|
|
update.setDiagnose(basicInfoDto.getDiagnose());
|
|
|
@@ -263,6 +278,9 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int submitPrescribe(FsPrescribeDataSubmitDto submitDto) {
|
|
|
+ if (getPrescribeIsDocument(submitDto.getPrescribeId())){
|
|
|
+ throw new CustomException("销售已制单,当前操作不可执行,请刷新后重试!");
|
|
|
+ }
|
|
|
// 1. 清除原处方图片(如果有)
|
|
|
clearPrescriptionImage(submitDto.getPrescribeId());
|
|
|
|
|
|
@@ -270,6 +288,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
FsPrescribeDataScrm update = new FsPrescribeDataScrm();
|
|
|
BeanCopyUtils.copy(submitDto, update);
|
|
|
update.setDoctorConfirm(1); // 确认开方
|
|
|
+ update.setStatus(0); // 待药师审核
|
|
|
int updateCount = fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(update);
|
|
|
|
|
|
// 3. 全量覆盖药品列表(删除旧的全部,插入新的)
|
|
|
@@ -281,7 +300,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
syncDrugsFullCover(submitDto.getPrescribeId(), submitDto.getDrugs());
|
|
|
}
|
|
|
|
|
|
- // 4. 异步生成处方图片(根据处方类型和药品)
|
|
|
+ // 4. 生成医生签名处方图片任务(根据处方类型和药品)
|
|
|
submitPrescribeImageTask(submitDto.getPrescribeId(), 1);
|
|
|
|
|
|
// 5. 更新用户状态为待审核(如果有需要)
|
|
|
@@ -372,123 +391,7 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
companyCustomerMapper.updateFsCompanyCustomer(mapCustomer);
|
|
|
}
|
|
|
|
|
|
- // ==================== 处方图片生成 ====================
|
|
|
- /**
|
|
|
- * 生成处方图片(异步任务调用)
|
|
|
- * @param prescribeId 处方ID
|
|
|
- * @param signFlag 签名标识:1-仅医生签名,2-医生+药师签名
|
|
|
- * @return Map 包含两个 key:
|
|
|
- * "prescribeImgUrl" - 中药处方图片地址
|
|
|
- * "prescribeImgStoreUrl" - 西药处方图片地址
|
|
|
- * 未生成对应的图片时 value 为 null
|
|
|
- */
|
|
|
- @Override
|
|
|
- public Map<String, String> prescribeScrmImgYsyTask(Long prescribeId, Integer signFlag) {
|
|
|
- FsPrescribeDataScrmImgVO imgVO = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmImgVOByPrescribeId(prescribeId);
|
|
|
- Asserts.notNull(imgVO, String.format("处方 %d 未找到!", prescribeId));
|
|
|
- Asserts.notNull(imgVO.getDoctorId(), String.format("医生 %s 未找到!", imgVO.getDoctorId()));
|
|
|
- Asserts.notNull(imgVO.getDrugDoctorId(), String.format("药师 %s 未找到!", imgVO.getDrugDoctorId()));
|
|
|
-
|
|
|
- // 1. 获取并过滤药品
|
|
|
- FsPrescribeDataScrmDrug query = new FsPrescribeDataScrmDrug();
|
|
|
- query.setPrescribeId(prescribeId);
|
|
|
- List<FsPrescribeDataScrmDrug> drugList = dataScrmDrugMapper.selectFsPrescribeDataScrmDrugList(query);
|
|
|
- if (CollectionUtils.isEmpty(drugList)) {
|
|
|
- throw new CustomException(String.format("处方单 %d 对应药品为空!", prescribeId));
|
|
|
- }
|
|
|
-
|
|
|
- List<FsPrescribeDataScrmDrug> effectiveDrugs = filterNonDrugScrmPrescribe(drugList);
|
|
|
-
|
|
|
- // 2. 按药品类型分组
|
|
|
- Map<Integer, List<FsPrescribeDataScrmDrug>> drugTypeMap = effectiveDrugs.stream()
|
|
|
- .collect(Collectors.groupingBy(FsPrescribeDataScrmDrug::getDrugType));
|
|
|
- List<FsPrescribeDataScrmDrug> westernDrugs = drugTypeMap.getOrDefault(1, Collections.emptyList()); // 西药
|
|
|
- List<FsPrescribeDataScrmDrug> chineseDrugs = drugTypeMap.getOrDefault(2, Collections.emptyList()); // 中药
|
|
|
-
|
|
|
- // 3. 根据处方类型决定要生成的图片
|
|
|
- Integer prescribeType = imgVO.getPrescribeType();
|
|
|
- boolean needWestern = (prescribeType == 1 || prescribeType == 3) && !westernDrugs.isEmpty();
|
|
|
- boolean needChinese = (prescribeType == 2 || prescribeType == 3) && !chineseDrugs.isEmpty();
|
|
|
-
|
|
|
- // 4. 分别生成图片并更新数据库
|
|
|
- FsPrescribeDataScrm updateData = new FsPrescribeDataScrm();
|
|
|
- updateData.setPrescribeId(prescribeId);
|
|
|
- boolean hasUpdate = false;
|
|
|
-
|
|
|
- // 生成西药图片 → prescribeImgStoreUrl
|
|
|
- if (needWestern) {
|
|
|
- if (StringUtils.isBlank(imgVO.getPrescribeImgStoreUrl())) {
|
|
|
- String url = generatePrescriptionImageForType(imgVO, signFlag, westernDrugs);
|
|
|
- updateData.setPrescribeImgStoreUrl(url);
|
|
|
- hasUpdate = true;
|
|
|
- } else {
|
|
|
- log.info("处方 {} 西药图片已存在,跳过生成", prescribeId);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 生成中药图片 → prescribeImgUrl
|
|
|
- if (needChinese) {
|
|
|
- if (StringUtils.isBlank(imgVO.getPrescribeImgUrl())) {
|
|
|
- String url = generatePrescriptionImageForType(imgVO, signFlag, chineseDrugs);
|
|
|
- updateData.setPrescribeImgUrl(url);
|
|
|
- hasUpdate = true;
|
|
|
- } else {
|
|
|
- log.info("处方 {} 中药图片已存在,跳过生成", prescribeId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (hasUpdate) {
|
|
|
- fsPrescribeDataScrmMapper.updateFsPrescribeDataScrm(updateData);
|
|
|
- }
|
|
|
-
|
|
|
- // 5. 构建返回结果(重新查询一次确保拿到最新值)
|
|
|
- FsPrescribeDataScrmImgVO latest = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmImgVOByPrescribeId(prescribeId);
|
|
|
- Map<String, String> result = new HashMap<>();
|
|
|
- result.put("prescribeImgUrl", latest != null ? latest.getPrescribeImgUrl() : null);
|
|
|
- result.put("prescribeImgStoreUrl", latest != null ? latest.getPrescribeImgStoreUrl() : null);
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 生成处方图片(按药品类型)
|
|
|
- */
|
|
|
- private String generatePrescriptionImageForType(FsPrescribeDataScrmImgVO imgVO,
|
|
|
- Integer signFlag,
|
|
|
- List<FsPrescribeDataScrmDrug> drugList) {
|
|
|
- PrescribeXyImgParam imgParam = new PrescribeXyImgParam();
|
|
|
- imgParam.setTime(imgVO.getCreateTime());
|
|
|
- imgParam.setPrescribeId(imgVO.getPrescribeCode());
|
|
|
- imgParam.setPatientName(imgVO.getPatientName());
|
|
|
- imgParam.setPatientGender(String.valueOf(imgVO.getPatientGender()));
|
|
|
- imgParam.setPatientAge(imgVO.getPatientAge());
|
|
|
- imgParam.setOutpatientId(imgVO.getPrescribeCode());
|
|
|
-
|
|
|
- if (com.fs.common.utils.StringUtils.isNotBlank(imgVO.getRemark())) {
|
|
|
- imgParam.setRemark(imgVO.getRemark());
|
|
|
- } else {
|
|
|
- log.error("PrescribeImgYsyTask 处方id:{},缺失医嘱内容", imgVO.getPrescribeId());
|
|
|
- imgParam.setRemark("请按照用药说明书服用药品,如有不适,请及时就医!");
|
|
|
- }
|
|
|
-
|
|
|
- imgParam.setHistoryAllergic(imgVO.getHistoryAllergic());
|
|
|
- imgParam.setDiagnose(imgVO.getDiagnose());
|
|
|
- imgParam.setPrescribeDrug(convertToPrescribeDrugList(drugList));
|
|
|
-
|
|
|
- // 签名设置(保底默认全部签名)
|
|
|
- imgParam.setUrl(imgVO.getDoctorSign());
|
|
|
- if (signFlag == null || signFlag == 2) {
|
|
|
- imgParam.setDrugDoctorUrl(imgVO.getDrugDoctorSignUrl());
|
|
|
- }
|
|
|
-
|
|
|
- imgParam.setDoctorName(imgVO.getDoctorName());
|
|
|
- imgParam.setAuditDoctor(imgVO.getDrugDoctorName());
|
|
|
- imgParam.setTelPhone(imgVO.getPatientTel());
|
|
|
- imgParam.setJobLicenseNumber(imgVO.getPractiseCode());
|
|
|
- imgParam.setDoctorNo(imgVO.getDoctorCertificate());
|
|
|
- imgParam.setDoctorTitle(imgVO.getDoctorPosition());
|
|
|
-
|
|
|
- return prescriptionImageService.generatePrescriptionImage(imgParam);
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public void clearPrescribeUrl(Long prescribeId) {
|
|
|
@@ -524,91 +427,18 @@ public class FsPrescribeDataScrmServiceImpl implements IFsPrescribeDataScrmServi
|
|
|
self().clearPrescribeUrl(prescribeId);
|
|
|
}
|
|
|
|
|
|
- // ==================== 药品过滤与转换 ====================
|
|
|
/**
|
|
|
- * 根据产品最新状态过滤处方单药品列表。
|
|
|
- * <p>
|
|
|
- * 该方法的过滤规则如下:
|
|
|
- * - 对于 productId 非空的处方药,使用其对应产品表(FsStoreProduct)中的 isDrug 状态进行判断,只保留 isDrug=1 的项。
|
|
|
- * - 对于 productId 为空的处方药,直接使用其自身的 isDrug 状态进行判断,只保留 isDrug=1 的项。
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @param prescribeDrugs 待过滤的处方单药品列表。如果为 null 或空,则直接返回空列表。
|
|
|
- * @return 一个符合上述规则的新列表。
|
|
|
- */
|
|
|
- public List<FsPrescribeDataScrmDrug> filterNonDrugScrmPrescribe(List<FsPrescribeDataScrmDrug> prescribeDrugs) {
|
|
|
- if (CollectionUtils.isEmpty(prescribeDrugs)) {
|
|
|
- return Collections.emptyList();
|
|
|
- }
|
|
|
-
|
|
|
- Set<Long> productIds = prescribeDrugs.stream()
|
|
|
- .map(FsPrescribeDataScrmDrug::getProductId)
|
|
|
- .filter(Objects::nonNull)
|
|
|
- .collect(Collectors.toSet());
|
|
|
-
|
|
|
- List<FsStoreProductScrm> storeProductIns = Collections.emptyList();
|
|
|
- if (!productIds.isEmpty()) {
|
|
|
- storeProductIns = fsStoreProductScrmMapper.getStoreProductInProductIds(new ArrayList<>(productIds));
|
|
|
- if (storeProductIns.isEmpty()) {
|
|
|
- log.error("查询产品id列表:{}查询产品信息为空!", productIds);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Map<Long, FsStoreProductScrm> storeProductMap = storeProductIns.stream()
|
|
|
- .collect(Collectors.toMap(FsStoreProductScrm::getProductId, Function.identity()));
|
|
|
-
|
|
|
- List<FsPrescribeDataScrmDrug> filteredDrugs = new ArrayList<>();
|
|
|
- for (FsPrescribeDataScrmDrug drug : prescribeDrugs) {
|
|
|
- boolean shouldKeep = false;
|
|
|
- if (drug.getProductId() != null) {
|
|
|
- FsStoreProductScrm product = storeProductMap.get(drug.getProductId());
|
|
|
- if (product != null) {
|
|
|
- shouldKeep = Integer.valueOf(1).equals(product.getIsDrug());
|
|
|
- } else {
|
|
|
- log.warn("药品 '{}' (ID: {}) 在产品表中未找到对应记录,将被过滤。", drug.getDrugName(), drug.getProductId());
|
|
|
- }
|
|
|
- } else {
|
|
|
- shouldKeep = Integer.valueOf(1).equals(drug.getIsDrug());
|
|
|
- }
|
|
|
-
|
|
|
- if (shouldKeep) {
|
|
|
- filteredDrugs.add(drug);
|
|
|
- }
|
|
|
- }
|
|
|
- return filteredDrugs;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 转换处方单药品列表
|
|
|
+ * 获取处方单的最新制单状态,若销售已制单,所有的处方写操作都不可执行
|
|
|
+ * @return true:已制单,false:未制单
|
|
|
* */
|
|
|
- private List<FsPrescribeDrug> convertToPrescribeDrugList(List<FsPrescribeDataScrmDrug> sourceList) {
|
|
|
- if (sourceList == null || sourceList.isEmpty()) {
|
|
|
- return new ArrayList<>();
|
|
|
+ private Boolean getPrescribeIsDocument(Long prescribeId) {
|
|
|
+ FsPrescribeDataScrm fsPrescribeDataScrm = fsPrescribeDataScrmMapper.selectFsPrescribeDataScrmByPrescribeId(prescribeId);
|
|
|
+ if (fsPrescribeDataScrm == null){
|
|
|
+ throw new CustomException("未查询到有效处方信息");
|
|
|
+ }
|
|
|
+ if (fsPrescribeDataScrm.getIsDocument() == 1){
|
|
|
+ return true;
|
|
|
}
|
|
|
- return sourceList.stream()
|
|
|
- .map(source -> {
|
|
|
- FsPrescribeDrug target = new FsPrescribeDrug();
|
|
|
- target.setDrugId(source.getDrugId());
|
|
|
- target.setPrescribeId(source.getPrescribeId());
|
|
|
- target.setDrugName(source.getDrugName());
|
|
|
- target.setDrugSpec(source.getDrugSpec());
|
|
|
- target.setUsageMethod(source.getUsageMethod());
|
|
|
- target.setUsageFrequencyUnit(source.getUsageFrequencyUnit());
|
|
|
- target.setUsagePerUseCount(source.getUsagePerUseCount());
|
|
|
- target.setUsagePerUseUnit(source.getUsagePerUseUnit());
|
|
|
- target.setUsageDays(source.getUsageDays());
|
|
|
- target.setDrugPrice(source.getDrugPrice());
|
|
|
- target.setDrugUnit(source.getDrugUnit());
|
|
|
- target.setInstructions(source.getInstructions());
|
|
|
- target.setProductId(source.getProductId());
|
|
|
- target.setDrugImgUrl(source.getDrugImgUrl());
|
|
|
- target.setProductAttrValueId(source.getProductAttrValueId());
|
|
|
- target.setRemark(source.getRemark());
|
|
|
- target.setDrugType(source.getDrugType());
|
|
|
- target.setIsDrug(source.getIsDrug());
|
|
|
- target.setDrugNum(source.getDrugNum());
|
|
|
- return target;
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|