|
|
|
@ -7,13 +7,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.supervision.exception.BusinessException;
|
|
|
|
|
import com.supervision.manage.pojo.vo.MedicalRecManageVO;
|
|
|
|
|
import com.supervision.model.AskPatientAnswer;
|
|
|
|
|
import com.supervision.model.MedicalRec;
|
|
|
|
|
import com.supervision.model.Patient;
|
|
|
|
|
import com.supervision.model.*;
|
|
|
|
|
import com.supervision.service.AskPatientAnswerService;
|
|
|
|
|
import com.supervision.vo.manage.MedicalRecPageResVO;
|
|
|
|
|
import com.supervision.manage.service.MedicalRecManageService;
|
|
|
|
|
import com.supervision.model.Disease;
|
|
|
|
|
import com.supervision.service.DiseaseService;
|
|
|
|
|
import com.supervision.service.MedicalRecService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@ -21,7 +18,12 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Optional;
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
@ -70,4 +72,32 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
|
|
|
|
|
}
|
|
|
|
|
askPatientAnswerService.saveBatch(qaList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void modifyMedicalRec(MedicalRecManageVO reqVO) {
|
|
|
|
|
// 首先修改病人
|
|
|
|
|
Patient patient = reqVO.getPatient();
|
|
|
|
|
patient.updateById();
|
|
|
|
|
// 病历不允许修改
|
|
|
|
|
MedicalRec medicalRec = Optional.ofNullable(medicalRecService.getById(reqVO.getId())).orElseThrow(() -> new BusinessException("未找到病历信息"));
|
|
|
|
|
if (!StrUtil.equals(medicalRec.getDiseaseId(), reqVO.getDiseaseId())) {
|
|
|
|
|
throw new BusinessException("修改病例时,不允许修改疾病");
|
|
|
|
|
}
|
|
|
|
|
medicalRec.updateById();
|
|
|
|
|
// 然后修改问答
|
|
|
|
|
// 首先找到数据库中的问答
|
|
|
|
|
List<AskPatientAnswer> existQAList = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, medicalRec.getId()).list();
|
|
|
|
|
Map<String, AskPatientAnswer> existQAMap = existQAList.stream().collect(Collectors.toMap(AskPatientAnswer::getId, Function.identity()));
|
|
|
|
|
for (AskPatientAnswer askPatientAnswer : reqVO.getQaList()) {
|
|
|
|
|
if (StrUtil.isNotBlank(askPatientAnswer.getId())) {
|
|
|
|
|
// 存在的移除掉
|
|
|
|
|
existQAMap.remove(askPatientAnswer.getId());
|
|
|
|
|
askPatientAnswer.updateById();
|
|
|
|
|
} else {
|
|
|
|
|
askPatientAnswer.insert();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 将删除的移除
|
|
|
|
|
askPatientAnswerService.removeByIds(existQAMap.values().stream().map(AskPatientAnswer::getId).collect(Collectors.toSet()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|