修改一版

Uat_Study
he 2022-07-22 14:12:33 +08:00
parent 494d0c53ae
commit 104c899a32
4 changed files with 78 additions and 29 deletions

View File

@ -162,7 +162,9 @@ namespace IRaCIS.Core.Application.ViewModel
//public String TrialSiteCode { get; set; } = String.Empty;
//public Guid TrialId { get; set; }
public Guid? SubjectId { get; set; }
public int Index { get; set; } = 0;
public Guid SubjectId { get; set; }
public string SubjectCode { get; set; } = String.Empty;
public bool IsUrgent => UnReadTaskList.Any(t => t.IsUrgent);
@ -180,7 +182,15 @@ namespace IRaCIS.Core.Application.ViewModel
{
public Guid Id { get; set; }
public ReadingCategory ReadingCategory { get; set; }
public bool IsUrgent { get; set; }
public decimal VisitNum { get; set; }
public string TaskBlindName { get; set; }
public Guid? VisistId { get; set; }
public DateTime? SuggesteFinishedTime { get; set; }
}

View File

@ -15,5 +15,7 @@ namespace IRaCIS.Core.Application.Service
Task<IResponseOutput> ApplyReReading(ApplyReReadingCommand applyReReadingCommand);
Task<IResponseOutput> ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService);
(int, IOrderedQueryable<IRUnReadSubjectView>) GetOrderReadingIQueryable(Guid trialId);
}
}

View File

@ -987,7 +987,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
/// </summary>
/// <param name="trialId"></param>
/// <returns></returns>
public (int,IOrderedQueryable<IRUnReadSubjectView>?) GetOrderReadingIQueryable(Guid trialId)
public (int,IOrderedQueryable<IRUnReadSubjectView>) GetOrderReadingIQueryable(Guid trialId)
{
var visitGroupQuery = _visitTaskRepository.Where(x => x.TrialId == trialId && x.DoctorUserId == _userInfo.Id)
.Where(x => !x.Subject.IsDeleted)
@ -1001,8 +1001,16 @@ namespace IRaCIS.Core.Application.Service.Allocation
UnReadTaskCount = x.Where(y => y.ReReadingApplyState != ReReadingApplyState.HaveApplyed).Count(),
ExistReadingApply = x.Any(y => y.ReReadingApplyState == ReReadingApplyState.HaveApplyed),
UnReadTaskList = x.Where(y => y.ReReadingApplyState != ReReadingApplyState.HaveApplyed).OrderBy(x=>x.VisitTaskNum)
.Select(u => new IRUnreadTaskView() { Id = u.Id, IsUrgent = u.IsUrgent, SuggesteFinishedTime = u.SuggesteFinishedTime }).ToList(),
}).Where(x => x.UnReadTaskCount > 0).OrderBy(x => x.SubjectId);
.Select(u => new IRUnreadTaskView() {
Id = u.Id,
IsUrgent = u.IsUrgent,
VisitNum=u.VisitTaskNum,
TaskBlindName =u.TaskBlindName,
VisistId=u.SourceSubjectVisitId,
SuggesteFinishedTime = u.SuggesteFinishedTime,
ReadingCategory=u.ReadingCategory,
}).ToList(),
}).OrderBy(x => x.SubjectId);

View File

@ -31,6 +31,7 @@ namespace IRaCIS.Application.Services
private readonly IRepository<VisitTask> _visitTaskRepository;
private readonly IRepository<Trial> _trialRepository;
private readonly IVisitTaskHelpeService _visitTaskHelpeService;
private readonly IVisitTaskService _visitTaskService;
private readonly IReadingClinicalDataService _readingClinicalDataService;
private readonly IRepository<SubjectVisit> _subjectVisitRepository;
private readonly IRepository<Subject> _subjectRepository;
@ -49,6 +50,7 @@ namespace IRaCIS.Application.Services
IRepository<VisitTask> visitTaskRepository,
IRepository<Trial> TrialRepository,
IVisitTaskHelpeService visitTaskHelpeService,
IVisitTaskService visitTaskService,
IReadingClinicalDataService readingClinicalDataService,
IRepository<SubjectVisit> subjectVisitRepository,
IRepository<Subject> subjectRepository,
@ -66,6 +68,7 @@ namespace IRaCIS.Application.Services
this._visitTaskRepository = visitTaskRepository;
this._trialRepository = TrialRepository;
this._visitTaskHelpeService = visitTaskHelpeService;
this._visitTaskService = visitTaskService;
this._readingClinicalDataService = readingClinicalDataService;
this._subjectVisitRepository = subjectVisitRepository;
this._subjectRepository = subjectRepository;
@ -253,39 +256,65 @@ namespace IRaCIS.Application.Services
}
else if (inDto.SubjectId != null)
{
var subjectList = await _subjectRepository.Where(t => t.TrialId == inDto.TrialId)
.Select(s => new SubjectTask()
#region 之前的
//var subjectList = await _subjectRepository.Where(t => t.TrialId == inDto.TrialId)
//.Select(s => new SubjectTask()
//{
// SubjectId = s.Id,
// UnReadTaskCount = s.SubjectVisitTaskList.Count(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect),
//}).OrderBy(x => x.SubjectId).ToListAsync();
//subjectList = subjectList.Select((x, index) => new SubjectTask()
//{
// Index = index,
// SubjectId = x.SubjectId,
// UnReadTaskCount = x.UnReadTaskCount,
//}).ToList();
//var subjectIndex = subjectList.Where(x => x.SubjectId == inDto.SubjectId).Select(x => x.Index).FirstOrDefault();
//var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x => x.SubjectId).FirstOrDefault();
//var taskquery = _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto()
//{
// VisitTaskId = x.Id,
// TaskBlindName = x.TaskBlindName,
// ReadingCategory = x.ReadingCategory,
// VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
// VisitNum = x.VisitTaskNum,
//}).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory);
#endregion
var subjectTaskList = await _visitTaskService.GetOrderReadingIQueryable(inDto.TrialId).Item2.ToListAsync();
var index = 0;
subjectTaskList.ForEach(x =>
{
SubjectId = s.Id,
UnReadTaskCount = s.SubjectVisitTaskList.Count(t => t.ReadingTaskState != ReadingTaskState.HaveSigned && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect),
}).OrderBy(x => x.SubjectId).ToListAsync();
subjectList = subjectList.Select((x, index) => new SubjectTask()
{
Index = index,
SubjectId = x.SubjectId,
UnReadTaskCount = x.UnReadTaskCount,
}).ToList();
x.Index = index;
index++;
});
var subjectIndex = subjectTaskList.Where(x => x.SubjectId == inDto.SubjectId).Select(x => x.Index).FirstOrDefault();
var subjectIndex = subjectList.Where(x => x.SubjectId == inDto.SubjectId).Select(x => x.Index).FirstOrDefault();
var newSubjectId = subjectList.Where(x => x.Index >= subjectIndex && x.UnReadTaskCount != 0).Select(x => x.SubjectId).FirstOrDefault();
var currentSubject = subjectTaskList.Where(x => x.Index >= 0).OrderBy(x => x.Index).FirstOrDefault();
var taskquery = _visitTaskRepository.Where(x => x.TrialId == inDto.TrialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == newSubjectId && x.DoctorUserId == _userInfo.Id&&x.TaskState==TaskState.Effect).Select(x => new GetReadingTaskDto()
{
VisitTaskId = x.Id,
TaskBlindName = x.TaskBlindName,
ReadingCategory = x.ReadingCategory,
VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId,
VisitNum = x.VisitTaskNum,
}).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory);
task = await taskquery.FirstOrDefaultAsync();
if (task == null)
if (currentSubject == null)
{
throw new BusinessValidationFailedException("任务都已经完成");
}
task.SubjectId = inDto.SubjectId.Value;
task = currentSubject.UnReadTaskList.Select(x => new GetReadingTaskDto()
{
ReadingCategory = x.ReadingCategory,
SubjectCode = currentSubject.SubjectCode,
SubjectId = currentSubject.SubjectId,
TaskBlindName = x.TaskBlindName,
VisitNum = x.VisitNum,
VisistId = x.VisistId ?? default(Guid),
VisitTaskId = x.Id
}).FirstOrDefault();
}