Uat_Study
parent
6295820804
commit
d751bca3ea
|
@ -30,6 +30,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid? DoctorUserId { get; set; }
|
||||
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public bool IsChangeOtherTask { get; set; }
|
||||
|
@ -96,6 +98,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public class VisitTaskAnswerInfo
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
public Guid QuestionId { get; set; }
|
||||
|
||||
public string VisitName { get; set; }
|
||||
|
||||
public decimal SOD { get; set; }
|
||||
|
|
|
@ -354,6 +354,13 @@ namespace IRaCIS.Application.Services
|
|||
public async Task<IResponseOutput> DeleteReadModule(Guid readModuleId)
|
||||
{
|
||||
|
||||
var readModule = await _readModuleRepository.Where(x => x.Id == readModuleId).FirstNotNullAsync();
|
||||
|
||||
if (readModule.ModuleType==ModuleTypeEnum.Global&&(await _readModuleRepository.AnyAsync(x=>x.ModuleType==ModuleTypeEnum.Oncology&&x.SubjectVisitId== readModule.SubjectVisitId)))
|
||||
{
|
||||
throw new BusinessValidationFailedException("当前访视存在肿瘤学阅片,请先删除肿瘤学阅片");
|
||||
}
|
||||
|
||||
if (await _visitTaskRepository.AnyAsync(x => readModuleId==x.SouceReadModuleId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect))
|
||||
{
|
||||
throw new BusinessValidationFailedException("当前阅片已生成任务并且阅片完成,操作失败。");
|
||||
|
|
|
@ -11,6 +11,7 @@ using IRaCIS.Core.Application.ViewModel;
|
|||
using Panda.DynamicWebApi.Attributes;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
namespace IRaCIS.Core.Application.Service
|
||||
{
|
||||
|
@ -36,7 +37,6 @@ namespace IRaCIS.Core.Application.Service
|
|||
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
|
||||
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
|
||||
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
|
||||
|
||||
IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<TumorAssessment> tumorAssessmentRepository,
|
||||
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswerRepository
|
||||
|
@ -52,6 +52,10 @@ namespace IRaCIS.Core.Application.Service
|
|||
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
|
||||
}
|
||||
|
||||
#region 临时对象 单个请求的生命周期 避免重复查询数据库
|
||||
private List<VisitTaskAnswerInfo> visitTaskAnswerList;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 计算任务
|
||||
/// </summary>
|
||||
|
@ -107,6 +111,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
CriterionId= criterionId,
|
||||
IsChangeOtherTask=inDto.IsChangeOtherTask,
|
||||
TrialId=visitTask.TrialId,
|
||||
DoctorUserId=visitTask.DoctorUserId,
|
||||
};
|
||||
await ReadingCalculate(readingData);
|
||||
}
|
||||
|
@ -122,21 +127,57 @@ namespace IRaCIS.Core.Application.Service
|
|||
// 找到所有访视任务的Id
|
||||
|
||||
var visitTaskIds = await _visitTaskRepository.Where(x => !x.IsAnalysisCreate && x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned).Select(x => x.Id).ToListAsync();
|
||||
x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&x.DoctorUserId==inDto.DoctorUserId).Select(x => x.Id).ToListAsync();
|
||||
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => x.QuestionType != null))
|
||||
|
||||
#region 先计算
|
||||
// 先计算然后保存结果 因为计算的结果在下面的计算可能会用到
|
||||
var needFirstCalculateTypes = new List<QuestionType?>()
|
||||
{
|
||||
QuestionType.SOD,
|
||||
};
|
||||
|
||||
var needFirstAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => needFirstCalculateTypes.Contains(x.QuestionType)))
|
||||
{
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
// 靶病灶径线之和(SOD)
|
||||
case QuestionType.SOD:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
needFirstAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODData(inDto)).ToString(),
|
||||
ReadingQuestionTrialId=item.QuestionId,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var needFirstAddIds = needFirstAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => needFirstAddIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needFirstAddList.ForEach(x =>
|
||||
{
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.TrialId = inDto.TrialId;
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
});
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needFirstAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
#endregion
|
||||
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
// 循环找要计算的值进行计算
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => x.QuestionType != null))
|
||||
{
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
|
||||
// 非淋巴结靶病灶长径之和
|
||||
case QuestionType.SumOfDiameter:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
|
@ -163,32 +204,59 @@ namespace IRaCIS.Core.Application.Service
|
|||
break;
|
||||
// 与整个访视期间最低点相比增加的值(mm) 其他任务需要改
|
||||
case QuestionType.LowestIncrease:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowestIncrease(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowestIncrease(inDto, item.QuestionId);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的百分比 其他任务需要改
|
||||
case QuestionType.LowPercent:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowPercent(inDto, item.QuestionId);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 整个访视期间最低点访视名称 其他任务需要改
|
||||
case QuestionType.LowVisit:
|
||||
var answer = (await GetLowVisit(inDto)).ToString();
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = answer,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inDto.IsChangeOtherTask)
|
||||
{
|
||||
await this.ChangeAllVisitTaskAnswer(visitTaskIds, item.QuestionId, answer);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// 是否存在非淋巴结靶病灶
|
||||
case QuestionType.IsLymphTarget:
|
||||
|
@ -381,7 +449,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
else
|
||||
{
|
||||
return decimal.Round(thisSOD * 100 / minSOD, 2);
|
||||
return decimal.Round((thisSOD- minSOD) * 100 / minSOD, 2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -495,6 +563,68 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 修改其他标准
|
||||
|
||||
#region 修改与整个访视期间最低点相比增加的值(mm)
|
||||
|
||||
/// <summary>
|
||||
/// 修改与整个访视期间最低点相比增加的值(mm)
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <param name="questionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ChangeAllLowestIncrease(ReadingCalculateDto inDto,Guid questionId)
|
||||
{
|
||||
var visitTaskList = await GetVisitTaskAnswerList(inDto);
|
||||
var lowSod = visitTaskList.Select(x => x.SOD).OrderBy(x => x).FirstOrDefault();
|
||||
foreach (var item in visitTaskList)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == item.VisitTaskId && x.ReadingQuestionTrialId == questionId, x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (item.SOD - lowSod).ToString()
|
||||
}) ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 修改整个访视期间最低点相比增加的百分比
|
||||
|
||||
/// <summary>
|
||||
/// 修改整个访视期间最低点相比增加的百分比
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <param name="questionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ChangeAllLowPercent(ReadingCalculateDto inDto, Guid questionId)
|
||||
{
|
||||
var visitTaskList = await GetVisitTaskAnswerList(inDto);
|
||||
var lowSod = visitTaskList.Select(x => x.SOD).OrderBy(x => x).FirstOrDefault();
|
||||
foreach (var item in visitTaskList)
|
||||
{
|
||||
decimal percent = 0;
|
||||
if (lowSod == 0)
|
||||
{
|
||||
percent= 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent= decimal.Round((item.SOD - lowSod) * 100 / lowSod, 2);
|
||||
}
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == item.VisitTaskId && x.ReadingQuestionTrialId == questionId, x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = percent.ToString()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 通用方法
|
||||
|
||||
#region 修改所有访视任务的答案
|
||||
|
@ -523,14 +653,14 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// <returns></returns>
|
||||
private async Task<decimal> GetBaseLineSOD(ReadingCalculateDto inDto)
|
||||
{
|
||||
if (await _visitTaskRepository.AnyAsync(x => x.Id == inDto.VisitTaskId && x.SourceSubjectVisit.IsBaseLine&&!x.IsAnalysisCreate))
|
||||
if (await _visitTaskRepository.AnyAsync(x => x.Id == inDto.VisitTaskId && x.SourceSubjectVisit.IsBaseLine&&!x.IsAnalysisCreate&&x.DoctorUserId==inDto.DoctorUserId))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 先找到基线的任务
|
||||
var baseLineTaskId = await _visitTaskRepository.Where(x => x.SubjectId == inDto.SubjectId && x.ReadingCategory == ReadingCategory.Visit
|
||||
&& x.SourceSubjectVisit.IsBaseLine && x.TaskState == TaskState.Effect&&!x.IsAnalysisCreate)
|
||||
&& x.SourceSubjectVisit.IsBaseLine && x.TaskState == TaskState.Effect&&!x.IsAnalysisCreate&&x.DoctorUserId==inDto.DoctorUserId)
|
||||
.Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
|
||||
|
@ -545,23 +675,23 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<List<VisitTaskAnswerInfo>> GetVisitTaskAnswerList(ReadingCalculateDto inDto)
|
||||
public async Task<List<VisitTaskAnswerInfo>> GetVisitTaskAnswerList(ReadingCalculateDto inDto)
|
||||
{
|
||||
var answerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTask.ReadingCategory == ReadingCategory.Visit
|
||||
if (visitTaskAnswerList == null)
|
||||
{
|
||||
visitTaskAnswerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTask.ReadingCategory == ReadingCategory.Visit
|
||||
&& x.SubjectId == inDto.SubjectId && x.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned && x.VisitTask.TaskState == TaskState.Effect && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD)
|
||||
.Select(x => new
|
||||
.Select(x => new VisitTaskAnswerInfo
|
||||
{
|
||||
VisitTaskId = x.VisitTaskId,
|
||||
QuestionId = x.ReadingQuestionTrialId,
|
||||
VisitName = x.VisitTask.SourceSubjectVisit.VisitName,
|
||||
SOD = x.Answer
|
||||
SOD = decimal.Parse(x.Answer.IsNullOrEmptyReturn0()),
|
||||
}).ToListAsync();
|
||||
|
||||
var decimalAnswerList = answerList.Select(x => new VisitTaskAnswerInfo
|
||||
{
|
||||
VisitName = x.VisitName,
|
||||
SOD = decimal.Parse(x.SOD.IsNullOrEmptyReturn0()),
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
return decimalAnswerList;
|
||||
return visitTaskAnswerList;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -579,7 +709,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
// 找到访视任务Id
|
||||
|
||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit && x.TaskState == TaskState.Effect && !x.IsAnalysisCreate && x.SourceSubjectVisitId == lastVisitId).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit && x.TaskState == TaskState.Effect && !x.IsAnalysisCreate && x.SourceSubjectVisitId == lastVisitId&&x.DoctorUserId==inDto.DoctorUserId).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
|
||||
return LastVisitTaskId;
|
||||
}
|
||||
|
|
|
@ -1867,6 +1867,12 @@ namespace IRaCIS.Application.Services
|
|||
}
|
||||
}
|
||||
|
||||
var isCurrentTaskAddList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex).Select(x => x.IsCurrentTaskAdd).ToListAsync();
|
||||
bool isCurrentTaskAdd = true;
|
||||
if (isCurrentTaskAddList.Count() > 0)
|
||||
{
|
||||
isCurrentTaskAdd = isCurrentTaskAddList[0];
|
||||
}
|
||||
|
||||
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex);
|
||||
|
@ -1883,13 +1889,14 @@ namespace IRaCIS.Application.Services
|
|||
VisitTaskId = inDto.VisitTaskId
|
||||
}).ToList();
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.AddAsync(new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
Id = NewId.NextGuid(),
|
||||
TrialId = inDto.TrialId,
|
||||
QuestionId = inDto.QuestionId,
|
||||
MeasureData = inDto.MeasureData,
|
||||
IsCurrentTaskAdd=true,
|
||||
IsCurrentTaskAdd= isCurrentTaskAdd,
|
||||
RowIndex = inDto.RowIndex,
|
||||
InstanceId=inDto.InstanceId,
|
||||
SeriesId=inDto.SeriesId,
|
||||
|
|
Loading…
Reference in New Issue