Uat_Study
he 2022-12-29 16:53:26 +08:00
parent 8cf077d9f1
commit 5ea5323112
5 changed files with 169 additions and 216 deletions

View File

@ -893,6 +893,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public Guid GlobalTaskId { get; set; }
public Guid? OtherGlobalTaskId { get; set; }
public ReadingTaskState ReadingTaskState { get; set; }
public string GlobalUpdateType { get; set; }

View File

@ -396,12 +396,21 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public bool IsSendMessage { get; set; }
public GetOncologyReadingInfoOutDto OncologyInfo { get; set; }
public GetGlobalReadingInfoOutDto GlobalInfo { get; set; }
public GetJudgeReadingInfoOutDto JudgeInfo { get; set; }
/// <summary>
/// 是否关闭
/// </summary>
public bool IsClosedDialog { get; set; }
public List<CriterionDictionaryInfo> OncologyAssessTypeList { get; set; }
public List<TaskInfo> TaskList { get; set; } = new List<TaskInfo>();

View File

@ -15,6 +15,12 @@ namespace IRaCIS.Core.Application.Contracts
Task<IResponseOutput> SubmitJudgeVisitTaskResult(SaveJudgeVisitTaskResult inDto);
Task<GetOncologyReadingInfoOutDto> GetOncologyReadingInfo(GetOncologyReadingInfoInDto inDto);
Task<GetJudgeReadingInfoOutDto> GetJudgeReadingInfo(GetJudgeReadingInfo inDto);
Task<GetGlobalReadingInfoOutDto> GetGlobalReadingInfo(GetGlobalReadingInfoInDto inDto);
Task<List<DicomReadingQuestionAnswer>> GetReadingQuestion(Guid trialReadingCriterionId, Guid? visitTaskId);

View File

@ -28,6 +28,8 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository<ReadingGlobalTaskInfo> _readingGlobalTaskInfoRepository;
private readonly IRepository<ReadingOncologyTaskInfo> _readingOncologyTaskInfoRepository;
private readonly IRepository<ReadingCriterionDictionary> _readingCriterionDictionaryRepository;
private readonly IReadingImageTaskService _iReadingImageTaskService;
private readonly IRepository<User> _userTaskRepository;
private readonly IVisitTaskService _visitTaskService;
private readonly IRepository<TaskMedicalReview> _taskMedicalReviewRepository;
@ -37,9 +39,10 @@ namespace IRaCIS.Core.Application.Service
private readonly IRepository<ReadingMedicineSystemQuestion> _readingMedicineSystemQuestionRepository;
public ReadingMedicalReviewService(
IRepository<ReadingMedicineTrialQuestion> readingMedicineTrialQuestionRepository,
IRepository<Trial> trialRepository,
IRepository<VisitTask> visitTaskRepository,
IRepository<ReadingMedicineTrialQuestion> readingMedicineTrialQuestionRepository,
IRepository<Trial> trialRepository,
IRepository<VisitTask> visitTaskRepository,
IReadingImageTaskService readingImageTaskService,
IRepository<ReadingTaskQuestionAnswer> readingTaskQuestionAnswerRepository,
IRepository<ReadingGlobalTaskInfo> readingGlobalTaskInfoRepository,
IRepository<ReadingOncologyTaskInfo> readingOncologyTaskInfoRepository,
@ -55,6 +58,7 @@ namespace IRaCIS.Core.Application.Service
{
this._readingMedicineTrialQuestionRepository = readingMedicineTrialQuestionRepository;
this._trialRepository = trialRepository;
this._iReadingImageTaskService = readingImageTaskService;
this._visitTaskRepository = visitTaskRepository;
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
this._readingGlobalTaskInfoRepository = readingGlobalTaskInfoRepository;
@ -118,111 +122,97 @@ namespace IRaCIS.Core.Application.Service
#region 取任务
// 先判断是否是肿瘤学任务
if (taskInfo.ReadingCategory == ReadingCategory.Oncology)
switch (taskInfo.ReadingCategory)
{
var oncologyList = await _readingOncologyTaskInfoRepository.Where(x => x.OncologyTaskId == taskInfo.Id).ToListAsync();
var taskIds= oncologyList.Select(x=>x.VisitTaskId).ToList();
medicalReviewInfo.TaskList = await _visitTaskRepository.Where(x=>
taskIds.Contains(x.Id)
).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
JudgeVisitTaskId = x.JudgeVisitTaskId,
JudgeResultArm = x.JudgeResultTask.ArmEnum,
SubjectId = x.SubjectId,
}).ToListAsync();
medicalReviewInfo.TaskList.ForEach(x =>
{
var oncologyInfo = oncologyList.Where(y => y.VisitTaskId == x.TaskId).FirstOrDefault();
if (oncologyInfo != null)
case ReadingCategory.Oncology:
medicalReviewInfo.OncologyInfo = await _iReadingImageTaskService.GetOncologyReadingInfo(new GetOncologyReadingInfoInDto()
{
x.OncologyEvaluationResult = oncologyInfo.EvaluationResult;
x.OncologyEvaluationReason = oncologyInfo.EvaluationReason;
}
});
VisitTaskId= taskInfo.Id
});
break;
case ReadingCategory.Judge:
medicalReviewInfo.JudgeInfo = await _iReadingImageTaskService.GetJudgeReadingInfo(new GetJudgeReadingInfo()
{
VisitTaskId = taskInfo.Id
});
break;
case ReadingCategory.Global:
medicalReviewInfo.GlobalInfo = await _iReadingImageTaskService.GetGlobalReadingInfo(new GetGlobalReadingInfoInDto()
{
VisitTaskId = taskInfo.Id
});
break;
case ReadingCategory.Visit:
// 有序
if (medicalReviewInfo.IsReadingTaskViewInOrder)
{
medicalReviewInfo.TaskList = await _visitTaskRepository
.Where(x => x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
.Where(x => x.TaskState == TaskState.Effect || x.Id == taskInfo.Id)
.Where(x => x.SubjectId == taskInfo.SubjectId
&& x.ArmEnum == taskInfo.ArmEnum
&&x.ReadingCategory== ReadingCategory.Visit
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
medicalReviewInfo.OncologyAssessTypeList = await _readingCriterionDictionaryRepository.Where(x => x.CriterionId == taskInfo.TrialReadingCriterionId
&& x.ParentCode == ReadingCommon.CriterionDictionary.OncologyAssess
)
.Select(x => new CriterionDictionaryInfo()
{
Id = x.Id,
DictionaryId = x.DictionaryId,
ChildGroup = x.Dictionary.ChildGroup,
Code = x.Dictionary.Code,
Description = x.Dictionary.Description,
ShowOrder = x.Dictionary.ShowOrder,
ParentCode = x.Dictionary.Parent.Code,
Value = x.Dictionary.Value,
ValueCN = x.Dictionary.ValueCN
}).OrderBy(x => x.ParentCode).ThenBy(x => x.ShowOrder).ToListAsync();
}
else
{
// 有序
if (medicalReviewInfo.IsReadingTaskViewInOrder)
{
medicalReviewInfo.TaskList = await _visitTaskRepository
.WhereIf(taskInfo.ArmEnum == Arm.JudgeArm, x => x.ArmEnum == Arm.JudgeArm)
.WhereIf(taskInfo.ArmEnum != Arm.JudgeArm, x => x.ArmEnum != Arm.JudgeArm)
.Where(x => x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
.Where(x => x.TaskState == TaskState.Effect||x.Id== taskInfo.Id)
.Where(x => x.SubjectId == taskInfo.SubjectId
&& x.ArmEnum == taskInfo.ArmEnum
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.DoctorUserId == taskInfo.DoctorUserId &&
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
x.ReReadingApplyState != ReReadingApplyState.Agree
).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
JudgeVisitTaskId = x.JudgeVisitTaskId,
JudgeResultArm = x.JudgeResultTask.ArmEnum,
SubjectId = x.SubjectId,
// 这里先只查裁判任务 访视和全局任务到后面查询
JudgeQuestionAnswerInfoList = x.JudgeResultTask.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.IsJudgeQuestion).Select(y => new JudgeQuestionAnswerInfo()
&& x.DoctorUserId == taskInfo.DoctorUserId &&
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
x.ReReadingApplyState != ReReadingApplyState.Agree
).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
VisitTaskId = y.VisitTaskId,
Answer = y.Answer,
QuestionName = y.ReadingQuestionTrial.QuestionName,
ShowOrder = y.ReadingQuestionTrial.ShowOrder,
DictionaryCode = y.ReadingQuestionTrial.DictionaryCode,
QuestionGenre = y.ReadingQuestionTrial.QuestionGenre,
}).OrderBy(x => x.ShowOrder).ToList(),
}).ToListAsync();
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
JudgeVisitTaskId = x.JudgeVisitTaskId,
JudgeResultArm = x.JudgeResultTask.ArmEnum,
SubjectId = x.SubjectId,
}).ToListAsync();
List<TaskInfo> otherTask = await _visitTaskRepository.Where(x => x.ArmEnum != Arm.JudgeArm && x.SubjectId == taskInfo.SubjectId
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&&x.TaskState==TaskState.Effect
&& x.ArmEnum == taskInfo.ArmEnum
&& x.DoctorUserId != taskInfo.DoctorUserId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ReReadingApplyState != ReReadingApplyState.Agree)
.Where(x => x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
.OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
List<TaskInfo> otherTask = await _visitTaskRepository.Where(x =>
x.SubjectId == taskInfo.SubjectId
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.TaskState == TaskState.Effect
&&x.ReadingCategory == ReadingCategory.Visit
&& x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis
&& x.DoctorUserId != taskInfo.DoctorUserId
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
&& x.ReReadingApplyState != ReReadingApplyState.Agree)
.OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
}).ToListAsync();
medicalReviewInfo.TaskList.ForEach(x =>
{
var otherTaskInfo = otherTask.Where(y => y.SouceReadModuleId == x.SouceReadModuleId && y.SourceSubjectVisitId == x.SourceSubjectVisitId).FirstOrDefault();
if (otherTaskInfo != null)
{
x.OtherTaskId = otherTaskInfo.TaskId;
x.OtherArmEnum = otherTaskInfo.ArmEnum;
}
});
}
// 无序
else
{
medicalReviewInfo.TaskList = await _visitTaskRepository.Where(x => x.Id == taskInfo.Id).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
@ -232,131 +222,75 @@ namespace IRaCIS.Core.Application.Service
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
SubjectId = x.SubjectId,
}).ToListAsync();
medicalReviewInfo.TaskList.ForEach(x =>
{
List<TaskInfo> otherTask = await _visitTaskRepository.Where(x =>
x.SouceReadModuleId == taskInfo.SouceReadModuleId
&& x.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId
&& x.DoctorUserId != taskInfo.DoctorUserId
&& x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
&& x.ReReadingApplyState != ReReadingApplyState.Agree
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.TaskState == TaskState.Effect
)
.OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
}).ToListAsync();
var otherTaskInfo = otherTask.Where(y => y.SouceReadModuleId == x.SouceReadModuleId && y.SourceSubjectVisitId == x.SourceSubjectVisitId).FirstOrDefault();
if (otherTaskInfo != null)
medicalReviewInfo.TaskList.ForEach(x =>
{
x.OtherTaskId = otherTaskInfo.TaskId;
x.OtherArmEnum = otherTaskInfo.ArmEnum;
}
});
}
// 无序
else
{
medicalReviewInfo.TaskList = await _visitTaskRepository.Where(x => x.Id == taskInfo.Id).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
SubjectId = x.SubjectId,
// 这里先只查裁判任务 访视和全局任务到后面查询
JudgeQuestionAnswerInfoList = x.JudgeResultTask.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.IsJudgeQuestion).Select(y => new JudgeQuestionAnswerInfo()
var otherTaskInfo = otherTask.Where(y => y.SouceReadModuleId == x.SouceReadModuleId && y.SourceSubjectVisitId == x.SourceSubjectVisitId).FirstOrDefault();
if (otherTaskInfo != null)
{
x.OtherTaskId = otherTaskInfo.TaskId;
x.OtherArmEnum = otherTaskInfo.ArmEnum;
}
});
}
var taskIds = medicalReviewInfo.TaskList.Select(x => x.TaskId).ToList();
// 找访视
var visitTaskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => taskIds.Contains(x.VisitTaskId) && x.ReadingQuestionTrial.IsJudgeQuestion).Select(x => new JudgeQuestionAnswerInfo
{
VisitTaskId = y.VisitTaskId,
Answer = y.Answer,
QuestionName = y.ReadingQuestionTrial.QuestionName,
ShowOrder = y.ReadingQuestionTrial.ShowOrder,
DictionaryCode = y.ReadingQuestionTrial.DictionaryCode,
QuestionGenre = y.ReadingQuestionTrial.QuestionGenre,
}).OrderBy(x => x.ShowOrder).ToList(),
}).ToListAsync();
List<TaskInfo> otherTask = await _visitTaskRepository.Where(x => x.ArmEnum != Arm.JudgeArm && x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId
&& x.DoctorUserId != taskInfo.DoctorUserId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ReReadingApplyState != ReReadingApplyState.Agree
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.TaskState==TaskState.Effect
)
.Where(x => x.IsAnalysisCreate == taskInfo.IsAnalysisCreate)
.OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo()
{
TaskId = x.Id,
IsCurrentTask = x.Id == taskInfo.Id,
ReadingCategory = x.ReadingCategory,
TaskBlindName = x.TaskBlindName,
ArmEnum = x.ArmEnum,
TaskName = x.TaskName,
SouceReadModuleId = x.SouceReadModuleId,
SourceSubjectVisitId = x.SourceSubjectVisitId,
Answer = x.Answer,
VisitTaskId = x.VisitTaskId,
DictionaryCode = x.ReadingQuestionTrial.DictionaryCode,
ShowOrder = x.ReadingQuestionTrial.ShowOrder,
QuestionGenre = x.ReadingQuestionTrial.QuestionGenre,
QuestionName = x.ReadingQuestionTrial.QuestionName
}).ToListAsync();
medicalReviewInfo.TaskList.ForEach(x =>
{
var otherTaskInfo = otherTask.Where(y => y.SouceReadModuleId == x.SouceReadModuleId && y.SourceSubjectVisitId == x.SourceSubjectVisitId).FirstOrDefault();
if(otherTaskInfo!=null)
var globalChangeAnswer = await _readingGlobalTaskInfoRepository.Where(x => taskIds.Contains(x.GlobalTaskId) && x.Answer != string.Empty && x.GlobalAnswerType == GlobalAnswerType.Question && x.GlobalVisitTask.TaskState == TaskState.Effect).ToListAsync();
medicalReviewInfo.TaskList.ForEach(x =>
{
x.OtherTaskId = otherTaskInfo.TaskId;
x.OtherArmEnum = otherTaskInfo.ArmEnum;
}
});
}
// 这里处理 访视和全局任务 以及肿瘤学
if (taskInfo.ArmEnum != Arm.JudgeArm)
{
var taskIds = medicalReviewInfo.TaskList.Select(x => x.TaskId).ToList();
// 找访视
var visitTaskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => taskIds.Contains(x.VisitTaskId) && x.ReadingQuestionTrial.IsJudgeQuestion).Select(x => new JudgeQuestionAnswerInfo
{
Answer = x.Answer,
VisitTaskId = x.VisitTaskId,
DictionaryCode = x.ReadingQuestionTrial.DictionaryCode,
ShowOrder = x.ReadingQuestionTrial.ShowOrder,
QuestionGenre = x.ReadingQuestionTrial.QuestionGenre,
QuestionName = x.ReadingQuestionTrial.QuestionName
}).ToListAsync();
var globalTaskAnswer = await (from global in _readingGlobalTaskInfoRepository.Where(x => taskIds.Contains(x.GlobalTaskId) && x.GlobalAnswerType == GlobalAnswerType.Question && x.TrialReadingQuestion.IsJudgeQuestion).Include(x=>x.TrialReadingQuestion)
join taskAnswer in _readingTaskQuestionAnswerRepository.AsQueryable() on new { TaskId= global.TaskId, QuestionId=global.QuestionId??default(Guid),TaskNum=global.GlobalVisitTask.VisitTaskNum- 0.03m } equals new { TaskId=taskAnswer.VisitTaskId, QuestionId=taskAnswer.ReadingQuestionTrialId , TaskNum=taskAnswer.VisitTask.VisitTaskNum }
select new JudgeQuestionAnswerInfo()
{
Answer = global.Answer.Trim().IsNullOrEmpty()? taskAnswer.Answer: global.Answer,
VisitTaskId = global.GlobalTaskId,
DictionaryCode = global.TrialReadingQuestion.DictionaryCode,
ShowOrder = global.TrialReadingQuestion.ShowOrder,
QuestionGenre = global.TrialReadingQuestion.QuestionGenre,
QuestionName = global.TrialReadingQuestion.QuestionName
}).ToListAsync();
visitTaskAnswer.AddRange(globalTaskAnswer);
var globalChangeAnswer = await _readingGlobalTaskInfoRepository.Where(x => taskIds.Contains(x.GlobalTaskId)&&x.Answer!=string.Empty && x.GlobalAnswerType == GlobalAnswerType.Question&&x.GlobalVisitTask.TaskState==TaskState.Effect).ToListAsync();
x.IsGlobalChange = globalChangeAnswer.Any(y => y.TaskId == x.TaskId);
x.JudgeQuestionAnswerInfoList = visitTaskAnswer.Where(y => y.VisitTaskId == x.TaskId).OrderBy(y => y.ShowOrder).ToList();
});
medicalReviewInfo.TaskList.ForEach(x =>
{
x.IsGlobalChange = globalChangeAnswer.Any(y => y.TaskId == x.TaskId);
x.JudgeQuestionAnswerInfoList = visitTaskAnswer.Where(y => y.VisitTaskId == x.TaskId).OrderBy(y => y.ShowOrder).ToList();
x.IsCurrentTask = x.TaskId == taskInfo.Id;
});
}
break;
}
medicalReviewInfo.TaskList.ForEach(x =>
{
x.IsCurrentTask = x.TaskId == taskInfo.Id;
});
#endregion
return medicalReviewInfo;

View File

@ -95,9 +95,11 @@ namespace IRaCIS.Application.Services
ReadingTaskState = taskInfo.ReadingTaskState,
};
result.OtherGlobalTaskId = await _visitTaskRepository.Where(x => x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis && x.TaskState == TaskState.Effect && x.DoctorUserId != taskInfo.DoctorUserId
).Select(x => x.Id).FirstOrDefaultAsync();
// 一致性分析按照doctorId 其他按照分组
result.TaskList = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
x.SubjectId == taskInfo.SubjectId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && x.TaskState == TaskState.Effect && x.VisitTaskNum < taskInfo.VisitTaskNum)