修改一版

Uat_Study
he 2022-08-30 13:23:42 +08:00
parent b15505f2ba
commit d4a1f6f113
6 changed files with 103 additions and 10 deletions

View File

@ -18,6 +18,8 @@ namespace IRaCIS.Core.Application.ViewModel
public Guid VisitTaskId { get; set; }
public Guid SubjectVisitId { get; set; }
public List<QuestionInfo> QuestionInfo { get; set; } = new List<QuestionInfo>();

View File

@ -66,7 +66,12 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public List<GetTrialReadingQuestionOutDto> RelationQuestions { get; set; } = new List<GetTrialReadingQuestionOutDto>();
}
public class GetTableAnswerRowInfoInDto
{
public Guid VisitTaskId { get; set; }
public Guid? QuestionId { get; set; }
}
public class GetReadingQuestionAndAnswerInDto
{
@ -621,6 +626,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public string MeasureData { get; set; }
public Guid? SeriesId { get; set; }
public Guid? InstanceId { get; set; }
public List<SubmitTableQuestionInfo> AnswerList { get; set; }

View File

@ -22,19 +22,25 @@ namespace IRaCIS.Core.Application.Service
{
private readonly IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository;
private readonly IRepository<VisitTask> _visitTaskRepository;
private readonly IRepository<TumorAssessment> _tumorAssessmentRepository;
private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository;
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
private readonly IRepository<TumorAssessment> _tumorAssessmentRepository;
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository;
public ReadingCalculateService(
IRepository<ReadingTableQuestionAnswer> readingTableQuestionAnswerRepository,
IRepository<VisitTask> visitTaskRepository,
IRepository<TumorAssessment> tumorAssessmentRepository,
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
IRepository<SubjectVisit> subjectVisitRepository,
IRepository<TumorAssessment> tumorAssessmentRepository,
IRepository<ReadingTaskQuestionAnswer> ReadingTaskQuestionAnswerRepository
)
{
this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository;
this._visitTaskRepository = visitTaskRepository;
this._tumorAssessmentRepository = tumorAssessmentRepository;
this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository;
this._subjectVisitRepository = subjectVisitRepository;
this._tumorAssessmentRepository = tumorAssessmentRepository;
this._readingTaskQuestionAnswerRepository = ReadingTaskQuestionAnswerRepository;
}
@ -226,9 +232,33 @@ namespace IRaCIS.Core.Application.Service
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<string> GetIsAddFive(ReadingCalculateDto inDto)
public async Task<bool> GetIsAddFive(ReadingCalculateDto inDto)
{
return string.Empty;
var LastVisitTaskId = await this.GetLastVisitTaskId(inDto);
var questionIds = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).Select(x => x.QuestionId).ToList();
var lastQuestionAsnwer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId && questionIds.Contains(x.QuestionId)).Include(x=>x.ReadingQuestionTrial).ToListAsync();
var rowIndexs = lastQuestionAsnwer.Where(x=>x.ReadingTableQuestionTrial.QuestionMark==QuestionMark.IsLymph&&x.Answer=="是").Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
var thisQuestionAsnwer = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList();
var isExists = false;
foreach (var item in rowIndexs)
{
var lastValue = decimal.Parse(lastQuestionAsnwer.Where(x => x.RowIndex == item && x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0");
var thisRowData = thisQuestionAsnwer.Where(x => x.RowIndex == item).SelectMany(x => x.TableQuestionList).ToList();
var thisValue = decimal.Parse(thisRowData.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0");
if (thisValue - lastValue > 5)
{
isExists = true;
}
}
return isExists;
}
#endregion
@ -275,14 +305,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))
if (await _visitTaskRepository.AnyAsync(x => x.Id == inDto.VisitTaskId && x.SourceSubjectVisit.IsBaseLine&&!x.IsAnalysisCreate))
{
return 0;
}
// 先找到基线的任务
var baseLineTaskId = await _visitTaskRepository.Where(x => x.SubjectId == inDto.SubjectId && x.ReadingCategory == ReadingCategory.Visit
&& x.SourceSubjectVisit.IsBaseLine && x.TaskState == TaskState.Effect)
&& x.SourceSubjectVisit.IsBaseLine && x.TaskState == TaskState.Effect&&!x.IsAnalysisCreate)
.Select(x => x.Id).FirstOrDefaultAsync();
@ -317,7 +347,24 @@ namespace IRaCIS.Core.Application.Service
}
#endregion
/// <summary>
/// 获取上一个访视任务Id
/// </summary>
/// <returns></returns>
private async Task<Guid> GetLastVisitTaskId(ReadingCalculateDto inDto)
{
// 拿到这一个访视
var thisNum = await _subjectVisitRepository.Where(x => x.Id == inDto.SubjectVisitId).Select(x => x.VisitNum).FirstOrDefaultAsync();
// 先找到上一个访视
var lastVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == inDto.SubjectId && x.VisitNum < thisNum).OrderByDescending(x => x.VisitNum).Select(x => x.Id).FirstOrDefaultAsync();
// 找到访视任务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();
return LastVisitTaskId;
}
#endregion
}

View File

@ -123,6 +123,20 @@ namespace IRaCIS.Application.Services
// result.SinglePage = groupList;
//}
/// <summary>
/// 获取表格答案行信息
/// </summary>
/// <param name="inDto"></param>
/// <remarks>
/// (QuestionId) 可为空
/// </remarks>
/// <returns></returns>
public async Task<List<ReadingTableAnswerRowInfo>> GetTableAnswerRowInfo(GetTableAnswerRowInfoInDto inDto)
{
return await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId)
.WhereIf(inDto.QuestionId != null, x => x.QuestionId == inDto.QuestionId)
.ToListAsync();
}
/// <summary>
/// 获取表格问题及答案2022-08-26
@ -279,6 +293,8 @@ namespace IRaCIS.Application.Services
answers.Add("MeasureData", rowInfo==null?string.Empty:rowInfo.MeasureData);
answers.Add("RowIndex", x.ToString());
answers.Add("InstanceId", rowInfo == null ? string.Empty : rowInfo.InstanceId.ToString());
answers.Add("SeriesId", rowInfo == null ? string.Empty : rowInfo.SeriesId.ToString());
item.TableQuestions.Answers.Add(answers);
});
@ -1532,6 +1548,7 @@ namespace IRaCIS.Application.Services
QuestionId=inDto.QuestionId,
TableQuestionId=x.TableQuestionId,
RowIndex=inDto.RowIndex,
VisitTaskId = inDto.VisitTaskId
}).ToList();
@ -1542,6 +1559,8 @@ namespace IRaCIS.Application.Services
QuestionId = inDto.QuestionId,
MeasureData = inDto.MeasureData,
RowIndex = inDto.RowIndex,
InstanceId=inDto.InstanceId,
SeriesId=inDto.SeriesId,
VisitTaskId = inDto.VisitTaskId,

View File

@ -29,10 +29,21 @@ namespace IRaCIS.Core.Domain.Models
/// TrialId
/// </summary>
public Guid TrialId { get; set; }
/// <summary>
/// RowIndex
/// </summary>
/// InstanceId
/// </summary>
public Guid? InstanceId { get; set; }
/// <summary>
/// SeriesId
/// </summary>
public Guid? SeriesId { get; set; }
/// <summary>
/// RowIndex
/// </summary>
public int RowIndex { get; set; }
/// <summary>

View File

@ -60,6 +60,10 @@ namespace IRaCIS.Core.Domain.Models
public ReadingQuestionTrial ReadingQuestionTrial { get; set; }
[ForeignKey("TableQuestionId")]
public ReadingTableQuestionTrial ReadingTableQuestionTrial { get; set; }
}