|
|
|
@ -50,7 +50,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
|
|
|
|
|
&& x.ReadingCategory == ReadingCategory.Visit
|
|
|
|
|
&& x.SubjectId == inDto.SubjectId
|
|
|
|
|
&& x.TaskState == TaskState.Effect).OrderByDescending(x => x.VisitTaskNum).Select(x=> x.VisitTaskNum).FirstOrDefaultAsync();
|
|
|
|
|
&& x.TaskState == TaskState.Effect).OrderByDescending(x => x.VisitTaskNum).Select(x => x.VisitTaskNum).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.LatestScanDate != null && !x.IsLostVisit);
|
|
|
|
@ -91,19 +91,125 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
throw new BusinessValidationFailedException(_localizer["ReadModule_CRCConfirmCanNtoEdit"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await _readModuleRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.Id, x => new ReadModule() {
|
|
|
|
|
SubjectVisitId=inDto.SubjectVisitIdId,
|
|
|
|
|
ModuleName=inDto.Name,
|
|
|
|
|
await _readModuleRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.Id, x => new ReadModule()
|
|
|
|
|
{
|
|
|
|
|
SubjectVisitId = inDto.SubjectVisitIdId,
|
|
|
|
|
ModuleName = inDto.Name,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return await _readModuleRepository.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IResponseOutput<PageOutput<GetReadModuleDtoOut>>> GetReadModuleList_New(GetReadModuleDto inQuery)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var criterionInfo = _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId).Select(t => new { t.CriterionName,t.ReadingType } ).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
var readingType = (int)criterionInfo.ReadingType;
|
|
|
|
|
|
|
|
|
|
var query = _subjectRepository.Where(t => t.TrialId == inQuery.TrialId)
|
|
|
|
|
.WhereIf(inQuery.SubjectId != null, x => x.Id == inQuery.SubjectId)
|
|
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.TrialSiteCode), x => x.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode))
|
|
|
|
|
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectCode), x => x.Code.Contains(inQuery.SubjectCode))
|
|
|
|
|
|
|
|
|
|
.Select(t => new GetReadModuleDtoOut()
|
|
|
|
|
{
|
|
|
|
|
SubjectCode = t.Code,
|
|
|
|
|
SubjectId = t.Id,
|
|
|
|
|
TrialSiteCode = t.TrialSite.TrialSiteCode,
|
|
|
|
|
TrialSiteId = t.TrialSiteId,
|
|
|
|
|
|
|
|
|
|
//访视要查询不失访的其次要查在 <= 截止访视的,截止访视没有就查这个受试者所有的
|
|
|
|
|
Data = t.SubjectVisitList.Where(t => t.IsLostVisit == false)
|
|
|
|
|
.Where(sv => t.FinalSubjectVisitId == null ? true : sv.VisitNum < t.LatestSubjectVisit.VisitNum).Select(sv => new ReadModuleView()
|
|
|
|
|
{
|
|
|
|
|
Id = sv.Id,
|
|
|
|
|
CreateTime = sv.CreateTime,
|
|
|
|
|
PDState = sv.PDState,
|
|
|
|
|
IsBaseLine = sv.IsBaseLine,
|
|
|
|
|
SubjectCode = sv.Subject.Code,
|
|
|
|
|
IsEnrollmentConfirm = sv.IsEnrollmentConfirm,
|
|
|
|
|
IsFinalVisit = sv.IsFinalVisit,
|
|
|
|
|
SubjectId = sv.SubjectId,
|
|
|
|
|
SubjectVisitId = sv.Id,
|
|
|
|
|
IsUrgent = sv.IsUrgent,
|
|
|
|
|
SubjectVisitName = sv.VisitName,
|
|
|
|
|
IsVisit = true,
|
|
|
|
|
|
|
|
|
|
Name = sv.VisitName,
|
|
|
|
|
TrialSiteId = sv.TrialSiteId,
|
|
|
|
|
TrialSiteCode = sv.TrialSite.TrialSiteCode,
|
|
|
|
|
|
|
|
|
|
TrialId = sv.TrialId,
|
|
|
|
|
VisitNum = sv.VisitNum,
|
|
|
|
|
TrialReadingCriterionId = inQuery.TrialReadingCriterionId,
|
|
|
|
|
|
|
|
|
|
OutPlanPreviousVisitId = sv.OutPlanPreviousVisitId,
|
|
|
|
|
|
|
|
|
|
OutPlanPreviousVisitName = sv.OutPlanPreviousVisit.VisitName,
|
|
|
|
|
|
|
|
|
|
ModuleType = sv.InPlan ? ModuleTypeEnum.InPlanSubjectVisit : ModuleTypeEnum.OutPlanSubjectVisit,
|
|
|
|
|
|
|
|
|
|
//只有阅片期有
|
|
|
|
|
CutOffVisitId = null,
|
|
|
|
|
CutOffVisitName = null,
|
|
|
|
|
ReadingSetType = null,
|
|
|
|
|
ReadModuleId = null,
|
|
|
|
|
ReadModuleName = "",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///阅片状态 0 1 2 保持访视的,任务全做完了就是5 没完成就是4 否则就是3
|
|
|
|
|
ReadingStatus = sv.ReadingStatus < ReadingStatusEnum.TaskAllocate ? sv.ReadingStatus :
|
|
|
|
|
(sv.VisitTaskList.Count(t => t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.ReadingTaskState == ReadingTaskState.HaveSigned
|
|
|
|
|
&& t.ReadingCategory != ReadingCategory.Judge && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) == readingType ? ReadingStatusEnum.ReadCompleted :
|
|
|
|
|
(sv.VisitTaskList.Count(t => t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.TaskAllocationState == TaskAllocationState.Allocated
|
|
|
|
|
&& t.ReadingCategory != ReadingCategory.Judge && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) == readingType ? ReadingStatusEnum.ImageReading : ReadingStatusEnum.TaskAllocate)),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//是否是截止访视?
|
|
|
|
|
IsCanChangeCutOffVisit = false,
|
|
|
|
|
|
|
|
|
|
//需要签名数量计算 基线包含subject+访视级别的
|
|
|
|
|
NeedSignClinicalDataCount = sv.Trial.TrialReadingCriterionList.Where(t=>t.Id==inQuery.TrialReadingCriterionId).SelectMany(u=>u.TrialClinicalDataSetCriterionList).Where(t => t.TrialClinicalDataSet.IsConfirm == true).
|
|
|
|
|
Where(t => sv.IsBaseLine ? t.TrialClinicalDataSet.ClinicalDataLevel <= ClinicalLevel.SubjectVisit : t.TrialClinicalDataSet.ClinicalDataLevel == ClinicalLevel.SubjectVisit).Count()
|
|
|
|
|
+ (sv.Trial.TrialReadingCriterionList.Where(t => t.Id == inQuery.TrialReadingCriterionId).SelectMany(u => u.TrialClinicalDataSetCriterionList).Where(t => t.TrialClinicalDataSet.IsConfirm == true)
|
|
|
|
|
.Any(t => t.TrialClinicalDataSet.ClinicalDataLevel == ClinicalLevel.Study)?1:0),
|
|
|
|
|
|
|
|
|
|
//签名的数量
|
|
|
|
|
|
|
|
|
|
SignClinicalDataCount = sv.ReadingClinicalDataList.Where(t=>t.IsSign==true && t.ClinicalDataTrialSet.ClinicalDataLevel!=ClinicalLevel.Study &&
|
|
|
|
|
t.ClinicalDataTrialSet.TrialClinicalDataSetCriteriaList.Any(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)).Count()
|
|
|
|
|
|
|
|
|
|
+( (sv.SubmitState==SubmitStateEnum.Submitted && sv.ReadingClinicalDataList.Where(t => t.IsSign == true && t.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.Study &&
|
|
|
|
|
t.ClinicalDataTrialSet.TrialClinicalDataSetCriteriaList.Any(t => t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)).Any())?1:0),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//标准名 应该是可以不查询的,只要保证逻辑正确
|
|
|
|
|
CriterionName = criterionInfo.CriterionName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) ; ;
|
|
|
|
|
|
|
|
|
|
var pageList= await query.ToPagedListAsync(inQuery) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseOutput.Ok(pageList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取读片模块 //加了标准参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<(PageOutput<GetReadModuleDtoOut>,object)> GetReadModuleList(GetReadModuleDto dto)
|
|
|
|
|
public async Task<(PageOutput<GetReadModuleDtoOut>, object)> GetReadModuleList(GetReadModuleDto dto)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
@ -125,7 +231,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
.WhereIf(dto.CompleteClinicalData == CompleteClinicalDataEnum.NotComplete, x => x.NeedSignClinicalDataCount != x.SignClinicalDataCount)
|
|
|
|
|
.WhereIf(dto.CompleteClinicalData == CompleteClinicalDataEnum.Complete, x => x.NeedSignClinicalDataCount != 0 && x.NeedSignClinicalDataCount == x.SignClinicalDataCount)
|
|
|
|
|
.WhereIf(dto.ReadingStatus != null, x => x.ReadingStatus == dto.ReadingStatus);
|
|
|
|
|
//.WhereIf(dto.Name != null, x => x.Name.Contains(dto.Name!)).OrderBy(x => x.SiteCode);
|
|
|
|
|
//.WhereIf(dto.Name != null, x => x.Name.Contains(dto.Name!)).OrderBy(x => x.SiteCode);
|
|
|
|
|
|
|
|
|
|
var subjectIds = await subjectQuery.OrderBy(dto.SortField).Select(x => x.SubjectId).Distinct().Skip((dto.PageIndex - 1) * dto.PageSize).Take(dto.PageSize).ToListAsync();
|
|
|
|
|
|
|
|
|
@ -137,7 +243,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
TrialSiteId = x.Key.TrialSiteId,
|
|
|
|
|
SubjectCode = x.Key.SubjectCode,
|
|
|
|
|
SubjectId = x.Key.SubjectId,
|
|
|
|
|
Data = x.OrderBy(x=>x.ModuleType).ThenBy(x=>x.VisitNum).ToList(),
|
|
|
|
|
Data = x.OrderBy(x => x.ModuleType).ThenBy(x => x.VisitNum).ToList(),
|
|
|
|
|
}).ToList();
|
|
|
|
|
PageOutput<GetReadModuleDtoOut> pageOutput = new PageOutput<GetReadModuleDtoOut>()
|
|
|
|
|
{
|
|
|
|
@ -161,23 +267,23 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
x.IsReadingPeriod,
|
|
|
|
|
x.ReadingInfoSignTime,
|
|
|
|
|
}).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (pageOutput, new
|
|
|
|
|
{
|
|
|
|
|
MaxLength = maxcount,
|
|
|
|
|
IsReadingTaskViewInOrder= criterionInfo.IsReadingTaskViewInOrder,
|
|
|
|
|
IsReadingTaskViewInOrder = criterionInfo.IsReadingTaskViewInOrder,
|
|
|
|
|
IsClinicalReading = criterionInfo.IsOncologyReading,
|
|
|
|
|
// OnlyExistsMedicalHistory = !(await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataSetName != "既往局部治疗史" && x.IsConfirm)),
|
|
|
|
|
IsExistsSubjectClinicalData= await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId&&x.ClinicalDataLevel== ClinicalLevel.Subject && x.IsConfirm&&x.TrialClinicalDataSetCriteriaList.Any(y=>y.TrialReadingCriterionId== dto.TrialReadingCriterionId)),
|
|
|
|
|
// OnlyExistsMedicalHistory = !(await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataSetName != "既往局部治疗史" && x.IsConfirm)),
|
|
|
|
|
IsExistsSubjectClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.Subject && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsVisitClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.SubjectVisit && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsStudyClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.Study && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsReadingClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.ImageRead && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsStudyClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.Study && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsReadingClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.ImageRead && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsExistsOncologyReadClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.TrialId == dto.TrialId && x.ClinicalDataLevel == ClinicalLevel.OncologyRead && x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
IsGlobalReading = criterionInfo.IsGlobalReading,
|
|
|
|
|
IsReadingPeriod=criterionInfo.IsReadingPeriod,
|
|
|
|
|
ReadingInfoSignTime=criterionInfo.ReadingInfoSignTime,
|
|
|
|
|
ExistClinicalData=await _clinicalDataTrialSetRepository.AnyAsync(x => x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
}) ;
|
|
|
|
|
IsReadingPeriod = criterionInfo.IsReadingPeriod,
|
|
|
|
|
ReadingInfoSignTime = criterionInfo.ReadingInfoSignTime,
|
|
|
|
|
ExistClinicalData = await _clinicalDataTrialSetRepository.AnyAsync(x => x.IsConfirm && x.TrialClinicalDataSetCriteriaList.Any(y => y.TrialReadingCriterionId == dto.TrialReadingCriterionId)),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
@ -195,8 +301,8 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
var data = await GetReadModuleList(new GetReadModuleDto()
|
|
|
|
|
{
|
|
|
|
|
SubjectId = dto.SubjectId,
|
|
|
|
|
TrialId=dto.TrialId,
|
|
|
|
|
TrialReadingCriterionId=dto.TrialReadingCriterionId,
|
|
|
|
|
TrialId = dto.TrialId,
|
|
|
|
|
TrialReadingCriterionId = dto.TrialReadingCriterionId,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
GetReadModuleSingleOutdto? readModule = data.Item1.CurrentPageData.FirstOrDefault().Data.Where(x => x.Id == dto.Id).Select(x => new GetReadModuleSingleOutdto()
|
|
|
|
@ -205,14 +311,14 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
ModuleType = x.ModuleType,
|
|
|
|
|
SubjectVisitId = x.SubjectVisitId,
|
|
|
|
|
SubjectVisitName = x.SubjectVisitName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Status = x.ReadingStatus,
|
|
|
|
|
}).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var stakeholderIds = new List<Guid>();
|
|
|
|
|
|
|
|
|
|
var subjectVisit =await _subjectVisitRepository.FirstOrDefaultAsync(x => x.Id == readModule.SubjectVisitId);
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.FirstOrDefaultAsync(x => x.Id == readModule.SubjectVisitId);
|
|
|
|
|
|
|
|
|
|
switch (readModule.Status)
|
|
|
|
|
{
|
|
|
|
@ -239,11 +345,11 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
case ReadingStatusEnum.ImageReading:
|
|
|
|
|
case ReadingStatusEnum.ReadCompleted:
|
|
|
|
|
|
|
|
|
|
var doctorUserId = await _visitTaskRepository.Where(x => (x.SouceReadModuleId == dto.Id || x.SourceSubjectVisitId == dto.Id)&&x.TaskState==TaskState.Effect)
|
|
|
|
|
var doctorUserId = await _visitTaskRepository.Where(x => (x.SouceReadModuleId == dto.Id || x.SourceSubjectVisitId == dto.Id) && x.TaskState == TaskState.Effect)
|
|
|
|
|
.Where(x => x.DoctorUserId != null).Select(x => x.DoctorUserId.Value).ToListAsync();
|
|
|
|
|
|
|
|
|
|
stakeholderIds.AddRange(doctorUserId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -261,26 +367,26 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
public async Task<List<GetSubjectReadVisitsOutDto>> GetSubjectReadVisitList(GetSubjectReadVisitsInDto inDto)
|
|
|
|
|
{
|
|
|
|
|
//增加标准
|
|
|
|
|
var maxReadVisit = await _readModuleRepository.Where(x => x.SubjectId == inDto.SubjectId && x.ReadingSetType==inDto.ReadingSetType && x.TrialReadingCriterionId==inDto.TrialReadingCriterionId).Include(x=>x.SubjectVisit).OrderByDescending(x=>x.SubjectVisit.VisitNum).FirstOrDefaultAsync();
|
|
|
|
|
var maxReadVisit = await _readModuleRepository.Where(x => x.SubjectId == inDto.SubjectId && x.ReadingSetType == inDto.ReadingSetType && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId).Include(x => x.SubjectVisit).OrderByDescending(x => x.SubjectVisit.VisitNum).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
var maxReadVisitNum= maxReadVisit==null?-1:maxReadVisit.SubjectVisit.VisitNum;
|
|
|
|
|
var maxReadVisitNum = maxReadVisit == null ? -1 : maxReadVisit.SubjectVisit.VisitNum;
|
|
|
|
|
var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.LatestScanDate != null && !x.IsLostVisit);
|
|
|
|
|
var finalVisitNum = await visitQuery.Where(x => x.IsFinalVisit).Select(x => x.VisitNum).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
//增加标准
|
|
|
|
|
var readModulequery = _readModuleRepository.AsQueryable().Where(x=>x.TrialReadingCriterionId == inDto.TrialReadingCriterionId);
|
|
|
|
|
var readModulequery = _readModuleRepository.AsQueryable().Where(x => x.TrialReadingCriterionId == inDto.TrialReadingCriterionId);
|
|
|
|
|
|
|
|
|
|
var resultlist= await visitQuery.WhereIf(finalVisitNum!=0, x => x.VisitNum <= finalVisitNum)
|
|
|
|
|
.WhereIf(inDto.ReadingSetType== ReadingSetType.TumorReading, x => readModulequery.Where(y => y.SubjectVisitId == x.Id&&y.TrialReadingCriterionId== inDto.TrialReadingCriterionId && y.ReadingSetType == ReadingSetType.ImageReading).Count() > 0)
|
|
|
|
|
.Where(x=>x.VisitNum> maxReadVisitNum)
|
|
|
|
|
.Where(x=>!x.IsBaseLine) // 排除基线
|
|
|
|
|
.Where(x => readModulequery.Where(y => y.SubjectVisitId == x.Id&& y.TrialReadingCriterionId == inDto.TrialReadingCriterionId && y.ReadingSetType == inDto.ReadingSetType).Count() == 0).OrderBy(x => finalVisitNum)
|
|
|
|
|
.Select(x => new GetSubjectReadVisitsOutDto()
|
|
|
|
|
{
|
|
|
|
|
SubjectVisitId = x.Id,
|
|
|
|
|
VisitName = x.VisitName,
|
|
|
|
|
VisitNum = x.VisitNum,
|
|
|
|
|
}).OrderBy(x=>x.VisitNum).ToListAsync();
|
|
|
|
|
var resultlist = await visitQuery.WhereIf(finalVisitNum != 0, x => x.VisitNum <= finalVisitNum)
|
|
|
|
|
.WhereIf(inDto.ReadingSetType == ReadingSetType.TumorReading, x => readModulequery.Where(y => y.SubjectVisitId == x.Id && y.TrialReadingCriterionId == inDto.TrialReadingCriterionId && y.ReadingSetType == ReadingSetType.ImageReading).Count() > 0)
|
|
|
|
|
.Where(x => x.VisitNum > maxReadVisitNum)
|
|
|
|
|
.Where(x => !x.IsBaseLine) // 排除基线
|
|
|
|
|
.Where(x => readModulequery.Where(y => y.SubjectVisitId == x.Id && y.TrialReadingCriterionId == inDto.TrialReadingCriterionId && y.ReadingSetType == inDto.ReadingSetType).Count() == 0).OrderBy(x => finalVisitNum)
|
|
|
|
|
.Select(x => new GetSubjectReadVisitsOutDto()
|
|
|
|
|
{
|
|
|
|
|
SubjectVisitId = x.Id,
|
|
|
|
|
VisitName = x.VisitName,
|
|
|
|
|
VisitNum = x.VisitNum,
|
|
|
|
|
}).OrderBy(x => x.VisitNum).ToListAsync();
|
|
|
|
|
|
|
|
|
|
return resultlist;
|
|
|
|
|
}
|
|
|
|
@ -295,8 +401,8 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
public async Task<IResponseOutput> AddReadModule(ReadModuleAddDto dto)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == dto.SubjectId);
|
|
|
|
|
|
|
|
|
|
var visitQuery = _subjectVisitRepository.Where(x => x.SubjectId == dto.SubjectId);
|
|
|
|
|
|
|
|
|
|
visitQuery = visitQuery
|
|
|
|
|
//.WhereIf(dto.ExpirationDate != null, x => x.LatestScanDate <= dto.ExpirationDate.Value)
|
|
|
|
@ -308,9 +414,9 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
if (visit != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == visit.Id&&x.ModuleType== moduleType && x.TrialReadingCriterionId == dto.TrialReadingCriterionId))
|
|
|
|
|
if (await _readModuleRepository.AnyAsync(x => x.SubjectVisitId == visit.Id && x.ModuleType == moduleType && x.TrialReadingCriterionId == dto.TrialReadingCriterionId))
|
|
|
|
|
{
|
|
|
|
|
//---当前访视已经添加过阅片期
|
|
|
|
|
//---当前访视已经添加过阅片期
|
|
|
|
|
throw new BusinessValidationFailedException(_localizer["ReadModule_AlreadyAdded"]);
|
|
|
|
|
}
|
|
|
|
|
var readModuleData = new ReadModule()
|
|
|
|
@ -323,7 +429,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
SubjectVisitId = visit.Id,
|
|
|
|
|
ReadingSetType = dto.ReadingSetType,
|
|
|
|
|
TrialId = dto.TrialId,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReadingStatus = ReadingStatusEnum.TaskAllocate,
|
|
|
|
|
|
|
|
|
|
//增加标准
|
|
|
|
@ -338,9 +444,9 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
{
|
|
|
|
|
case ModuleTypeEnum.Global:
|
|
|
|
|
//增加标准
|
|
|
|
|
var taskListInfo = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == readModuleData.SubjectVisitId&&x.TaskState==TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned
|
|
|
|
|
&&!x.IsAnalysisCreate && x.TrialReadingCriterionId==dto.TrialReadingCriterionId
|
|
|
|
|
|
|
|
|
|
var taskListInfo = await _visitTaskRepository.Where(x => x.SourceSubjectVisitId == readModuleData.SubjectVisitId && x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned
|
|
|
|
|
&& !x.IsAnalysisCreate && x.TrialReadingCriterionId == dto.TrialReadingCriterionId
|
|
|
|
|
|
|
|
|
|
).ToListAsync();
|
|
|
|
|
foreach (var taskInfo in taskListInfo)
|
|
|
|
|
{
|
|
|
|
@ -354,7 +460,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
{
|
|
|
|
|
IsUrgent = readModuleData.IsUrgent ?? false,
|
|
|
|
|
SubjectId = readModuleData.SubjectId,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReadingName = readModuleData.ModuleName,
|
|
|
|
|
ReadModuleId =readModuleData.Id,
|
|
|
|
|
ReadingCategory = ReadingCategory.Global,
|
|
|
|
@ -370,18 +476,18 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == dto.TrialReadingCriterionId).Select(x => new
|
|
|
|
|
{
|
|
|
|
|
x.ReadingType,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//增加标准
|
|
|
|
|
var globalModule = await _readModuleRepository.Where(x => x.SubjectId == readModuleData.SubjectId && x.SubjectVisitId == readModuleData.SubjectVisitId&& x.ModuleType == ModuleTypeEnum.Global && x.TrialReadingCriterionId == dto.TrialReadingCriterionId).FirstOrDefaultAsync();
|
|
|
|
|
var globalModule = await _readModuleRepository.Where(x => x.SubjectId == readModuleData.SubjectId && x.SubjectVisitId == readModuleData.SubjectVisitId && x.ModuleType == ModuleTypeEnum.Global && x.TrialReadingCriterionId == dto.TrialReadingCriterionId).FirstOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
if (globalModule != null)
|
|
|
|
|
{
|
|
|
|
|
var globalTaskInfoList = await _visitTaskRepository.Where(x => x.SouceReadModuleId == globalModule.Id
|
|
|
|
|
&& x.TrialReadingCriterionId == dto.TrialReadingCriterionId
|
|
|
|
|
&& x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&!x.IsAnalysisCreate).ToListAsync();
|
|
|
|
|
&& x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned && !x.IsAnalysisCreate).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (globalTaskInfoList.Count() > 0 && globalTaskInfoList.Count == (int)criterionInfo.ReadingType)
|
|
|
|
|
{
|
|
|
|
@ -408,7 +514,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
SubjectId = readModuleData.SubjectId,
|
|
|
|
|
VisitNum=visit.VisitNum,
|
|
|
|
|
ReadingName = readModuleData.ModuleName,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ReadModuleId =readModuleData.Id,
|
|
|
|
|
ReadingCategory = ReadingCategory.Oncology,
|
|
|
|
|
}
|
|
|
|
@ -420,9 +526,9 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//---请先添加全局阅片
|
|
|
|
|
//---请先添加全局阅片
|
|
|
|
|
return ResponseOutput.NotOk(_localizer["ReadModule_AddGlobalFirst"]);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@ -436,7 +542,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
return ResponseOutput.NotOk(_localizer["ReadModule_VisitNotFound"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -455,40 +561,40 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
var readModule = await _readModuleRepository.Where(x => x.Id == readModuleId).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(await _readingClinicalDataRepository.Where(t => t.ReadingId == readModuleId).AnyAsync(t => t.ReadingClinicalDataState == ReadingClinicalDataStatus.HaveSigned))
|
|
|
|
|
if (await _readingClinicalDataRepository.Where(t => t.ReadingId == readModuleId).AnyAsync(t => t.ReadingClinicalDataState == ReadingClinicalDataStatus.HaveSigned))
|
|
|
|
|
{
|
|
|
|
|
//---临床资料已签名,不允许删除
|
|
|
|
|
return ResponseOutput.NotOk(_localizer["ReadModule_SignedDataCannotDelete"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (await _readModuleRepository.AnyAsync(x => x.Id == readModuleId&&x.IsCRCConfirm))
|
|
|
|
|
|
|
|
|
|
if (await _readModuleRepository.AnyAsync(x => x.Id == readModuleId && x.IsCRCConfirm))
|
|
|
|
|
{
|
|
|
|
|
//---CRC已经确认临床数据 不允许删除
|
|
|
|
|
return ResponseOutput.NotOk(_localizer["ReadModule_CRCConfirmClinicalData"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//增加标准
|
|
|
|
|
if (readModule.ModuleType==ModuleTypeEnum.Global&&(await _readModuleRepository.AnyAsync(x=>x.ModuleType==ModuleTypeEnum.Oncology&&x.SubjectVisitId== readModule.SubjectVisitId && x.TrialReadingCriterionId==readModule.TrialReadingCriterionId)))
|
|
|
|
|
if (readModule.ModuleType == ModuleTypeEnum.Global && (await _readModuleRepository.AnyAsync(x => x.ModuleType == ModuleTypeEnum.Oncology && x.SubjectVisitId == readModule.SubjectVisitId && x.TrialReadingCriterionId == readModule.TrialReadingCriterionId)))
|
|
|
|
|
{
|
|
|
|
|
//---当前访视存在肿瘤学阅片,请先删除肿瘤学阅片
|
|
|
|
|
throw new BusinessValidationFailedException(_localizer["ReadModule_TumorExists"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (await _visitTaskRepository.AnyAsync(x => readModuleId==x.SouceReadModuleId))
|
|
|
|
|
if (await _visitTaskRepository.AnyAsync(x => readModuleId == x.SouceReadModuleId))
|
|
|
|
|
{
|
|
|
|
|
//---当前阅片已生成任务,操作失败。
|
|
|
|
|
throw new BusinessValidationFailedException(_localizer["ReadModule_TaskGenerated"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => readModuleId==x.SouceReadModuleId, x => new VisitTask()
|
|
|
|
|
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => readModuleId == x.SouceReadModuleId, x => new VisitTask()
|
|
|
|
|
{
|
|
|
|
|
TaskState = TaskState.Adbandon
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _readModuleRepository.UpdatePartialFromQueryAsync(t => t.Id == readModuleId, x => new ReadModule()
|
|
|
|
|
{
|
|
|
|
|