Uat_Study
parent
ecb7de083a
commit
b532ff775e
|
@ -8,6 +8,14 @@ using IRaCIS.Core.Domain.Share;
|
|||
using System.Collections.Generic;
|
||||
namespace IRaCIS.Core.Application.ViewModel
|
||||
{
|
||||
|
||||
public class CalculateTaskInDto
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
public bool IsChangeOtherTask { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 阅片计算Dto
|
||||
/// </summary>
|
||||
|
@ -18,6 +26,10 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
public Guid CriterionId { get; set; }
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public List<QuestionInfo> QuestionInfo { get; set; } = new List<QuestionInfo>();
|
||||
|
@ -29,7 +41,6 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public class QuestionInfo
|
||||
{
|
||||
|
||||
public Guid QuestionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -37,7 +48,6 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// </summary>
|
||||
public string Answer { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 病灶类型
|
||||
/// </summary>
|
||||
|
@ -45,11 +55,8 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
|
||||
public QuestionType? QuestionType { get; set; }
|
||||
|
||||
|
||||
|
||||
public List<TableRowInfo> TableRowInfoList = new List<TableRowInfo>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,6 +79,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
/// </summary>
|
||||
public Guid TableQuestionId { get; set; }
|
||||
|
||||
public Guid QuestionId { get; set; }
|
||||
|
||||
public int RowIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 问题标识
|
||||
|
|
|
@ -12,10 +12,6 @@ namespace IRaCIS.Core.Application.Interfaces
|
|||
/// </summary>
|
||||
public interface IReadingCalculateService
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Task CalculateTask(CalculateTaskInDto inDto);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,9 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
private readonly IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepository;
|
||||
private readonly IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository;
|
||||
private readonly IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository;
|
||||
private readonly IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository;
|
||||
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||
private readonly IRepository<TumorAssessment> _tumorAssessmentRepository;
|
||||
private readonly IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository;
|
||||
|
@ -30,18 +32,204 @@ namespace IRaCIS.Core.Application.Service
|
|||
public ReadingCalculateService(
|
||||
IRepository<ReadingTableQuestionAnswer> readingTableQuestionAnswerRepository,
|
||||
IRepository<VisitTask> visitTaskRepository,
|
||||
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
|
||||
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
|
||||
IRepository<ReadingTableQuestionTrial> readingTableQuestionTrialRepository,
|
||||
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
|
||||
|
||||
IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<TumorAssessment> tumorAssessmentRepository,
|
||||
IRepository<ReadingTaskQuestionAnswer> ReadingTaskQuestionAnswerRepository
|
||||
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswerRepository
|
||||
)
|
||||
{
|
||||
this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository;
|
||||
this._visitTaskRepository = visitTaskRepository;
|
||||
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
|
||||
this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository;
|
||||
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
|
||||
this._subjectVisitRepository = subjectVisitRepository;
|
||||
this._tumorAssessmentRepository = tumorAssessmentRepository;
|
||||
this._readingTaskQuestionAnswerRepository = ReadingTaskQuestionAnswerRepository;
|
||||
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算任务
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task CalculateTask(CalculateTaskInDto inDto)
|
||||
{
|
||||
var visitTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == visitTask.TrialId && x.IsConfirm).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
List<QuestionInfo> questionInfos = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).Select(x => new QuestionInfo()
|
||||
{
|
||||
LesionType=x.LesionType,
|
||||
QuestionId=x.Id,
|
||||
QuestionType=x.QuestionType,
|
||||
}).ToListAsync();
|
||||
|
||||
var questionAnswers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).Select(x => new
|
||||
{
|
||||
x.ReadingQuestionTrialId,
|
||||
x.Answer
|
||||
}).ToListAsync() ;
|
||||
|
||||
var tableQuestion = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).Include(x=>x.ReadingTableQuestionTrial).Select(x => new TableQuestionInfo()
|
||||
{
|
||||
Answer = x.Answer,
|
||||
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
||||
TableQuestionId = x.TableQuestionId,
|
||||
QuestionId=x.QuestionId,
|
||||
RowIndex=x.RowIndex,
|
||||
}).ToListAsync();
|
||||
|
||||
foreach (var item in questionInfos)
|
||||
{
|
||||
item.Answer = questionAnswers.Where(y => y.ReadingQuestionTrialId == item.QuestionId).Select(x => x.Answer).FirstOrDefault() ?? string.Empty;
|
||||
|
||||
var thisItemTableQuestions = tableQuestion.Where(x => x.QuestionId == item.QuestionId).ToList();
|
||||
|
||||
item.TableRowInfoList= thisItemTableQuestions.GroupBy(x=> new { x.RowIndex })
|
||||
.Select(g => new TableRowInfo()
|
||||
{
|
||||
RowIndex = g.Key.RowIndex,
|
||||
TableQuestionList = g.ToList()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
ReadingCalculateDto readingData = new ReadingCalculateDto()
|
||||
{
|
||||
SubjectId = visitTask.SubjectId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
SubjectVisitId = visitTask.SourceSubjectVisitId.Value,
|
||||
QuestionInfo = questionInfos,
|
||||
CriterionId= criterionId,
|
||||
TrialId=visitTask.TrialId,
|
||||
};
|
||||
await ReadingCalculate(readingData);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 自动计算
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ReadingCalculate(ReadingCalculateDto inDto)
|
||||
{
|
||||
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
foreach (var item in inDto.QuestionInfo)
|
||||
{
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
// 靶病灶径线之和(SOD)
|
||||
case QuestionType.SOD:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODData(inDto)).ToString(),
|
||||
ReadingQuestionTrialId=item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 非淋巴结靶病灶长径之和
|
||||
case QuestionType.SumOfDiameter:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSumOfDiameter(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线SOD相比变化量(mm)
|
||||
case QuestionType.SODChange:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODChange(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线访视相比SOD变化百分比
|
||||
case QuestionType.SODPercent:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的值(mm) 其他任务需要改
|
||||
case QuestionType.LowestIncrease:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowestIncrease(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的百分比 其他任务需要改
|
||||
case QuestionType.LowPercent:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 整个访视期间最低点访视名称 其他任务需要改
|
||||
case QuestionType.LowVisit:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowVisit(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 是否存在非淋巴结靶病灶
|
||||
case QuestionType.IsLymphTarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsLymphTarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 是否存在淋巴结靶病灶且该病灶比上一访视短径增加5MM以上
|
||||
case QuestionType.IsAddFive:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsAddFive(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 被评估为NE的单个靶病灶
|
||||
case QuestionType.NETarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetNETarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 整体肿瘤评估
|
||||
case QuestionType.Tumor:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetTumor(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var questionIds = needAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => questionIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needAddList.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(needAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,13 +251,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
foreach (var item in tableQuestion)
|
||||
{
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer == "是"))
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是"||x.Answer.ToLower()=="true".ToLower())))
|
||||
{
|
||||
// 淋巴结的短径
|
||||
result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0");
|
||||
}
|
||||
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer == "否"))
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower())))
|
||||
{
|
||||
// 非淋巴结的长径
|
||||
result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault() ?? "0");
|
||||
|
@ -97,7 +285,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
foreach (var item in tableQuestion)
|
||||
{
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer == "否"))
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "false".ToLower())))
|
||||
{
|
||||
// 非淋巴结的长径
|
||||
result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault() ?? "0");
|
||||
|
@ -216,7 +404,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
foreach (var item in tableQuestion)
|
||||
{
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer == "是"))
|
||||
if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower())))
|
||||
{
|
||||
return "是";
|
||||
}
|
||||
|
@ -232,14 +420,14 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> GetIsAddFive(ReadingCalculateDto inDto)
|
||||
public async Task<string> GetIsAddFive(ReadingCalculateDto inDto)
|
||||
{
|
||||
|
||||
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 rowIndexs = lastQuestionAsnwer.Where(x=>x.ReadingTableQuestionTrial.QuestionMark==QuestionMark.IsLymph&& (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower())).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
|
||||
|
||||
var thisQuestionAsnwer = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
|
@ -257,7 +445,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
}
|
||||
|
||||
return isExists;
|
||||
return isExists?"是":"否";
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
|
|
@ -17,6 +17,7 @@ using IRaCIS.Core.Infrastructure;
|
|||
using Newtonsoft.Json;
|
||||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Application.Interfaces;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
@ -35,6 +36,7 @@ namespace IRaCIS.Application.Services
|
|||
private readonly IVisitTaskHelpeService _visitTaskHelpeService;
|
||||
private readonly IVisitTaskService _visitTaskService;
|
||||
private readonly IReadingClinicalDataService _readingClinicalDataService;
|
||||
private readonly IReadingCalculateService _readingCalculateService;
|
||||
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
|
||||
private readonly IRepository<Subject> _subjectRepository;
|
||||
private readonly IRepository<ReadingGlobalTaskInfo> _readingGlobalTaskInfoRepository;
|
||||
|
@ -61,6 +63,7 @@ namespace IRaCIS.Application.Services
|
|||
IVisitTaskHelpeService visitTaskHelpeService,
|
||||
IVisitTaskService visitTaskService,
|
||||
IReadingClinicalDataService readingClinicalDataService,
|
||||
IReadingCalculateService readingCalculateService,
|
||||
IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<Subject> subjectRepository,
|
||||
IRepository<ReadingGlobalTaskInfo> readingGlobalTaskInfoRepository,
|
||||
|
@ -86,6 +89,7 @@ namespace IRaCIS.Application.Services
|
|||
this._visitTaskHelpeService = visitTaskHelpeService;
|
||||
this._visitTaskService = visitTaskService;
|
||||
this._readingClinicalDataService = readingClinicalDataService;
|
||||
this._readingCalculateService = readingCalculateService;
|
||||
this._subjectVisitRepository = subjectVisitRepository;
|
||||
this._subjectRepository = subjectRepository;
|
||||
this._readingGlobalTaskInfoRepository = readingGlobalTaskInfoRepository;
|
||||
|
@ -1567,6 +1571,11 @@ namespace IRaCIS.Application.Services
|
|||
});
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
await this._readingCalculateService.CalculateTask(new CalculateTaskInDto()
|
||||
{
|
||||
IsChangeOtherTask=false,
|
||||
VisitTaskId=inDto.VisitTaskId,
|
||||
});
|
||||
return ResponseOutput.Ok(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -271,17 +271,17 @@ namespace IRaCIS.Core.Domain.Share
|
|||
SODPercent = 3,
|
||||
|
||||
/// <summary>
|
||||
/// 与整个访视期间最低点相比增加的值(mm)
|
||||
/// 与整个访视期间最低点相比增加的值(mm) 其他任务需要改
|
||||
/// </summary>
|
||||
LowestIncrease = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 与整个访视期间最低点相比增加的百分比
|
||||
/// 与整个访视期间最低点相比增加的百分比 其他任务需要改
|
||||
/// </summary>
|
||||
LowPercent = 5,
|
||||
|
||||
/// <summary>
|
||||
/// 整个访视期间最低点访视名称
|
||||
/// 整个访视期间最低点访视名称 其他任务需要改
|
||||
/// </summary>
|
||||
LowVisit = 6,
|
||||
|
||||
|
|
Loading…
Reference in New Issue