Uat_Study
parent
2104677e46
commit
16d651d0c7
|
@ -8,6 +8,65 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||
{
|
||||
#region 阅片问题
|
||||
|
||||
|
||||
public class GetReadingQuestionAndAnswerOutDto
|
||||
{
|
||||
public List<TrialReadQuestionData> SinglePage { get; set; }
|
||||
|
||||
public List<TrialReadQuestionData> MultiPage { get; set; }
|
||||
|
||||
public List<TrialReadQuestionData> PublicPage { get; set; }
|
||||
}
|
||||
|
||||
public class TrialReadQuestionData : ReadingQuestionTrial
|
||||
{
|
||||
|
||||
public bool IsPage { get; set; } = false;
|
||||
|
||||
public string Answer { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分页名称
|
||||
/// </summary>
|
||||
public string PageName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否公共分页
|
||||
/// </summary>
|
||||
public bool? IsPublicPage { get; set; } = false;
|
||||
|
||||
public int PageShowOrder { get; set; }
|
||||
|
||||
public List<TrialReadQuestionData> Childrens { get; set; }
|
||||
|
||||
public TrialReadTableQuestion TableQuestions { get; set; }
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ReadingTableQuestionAnswerInfo : ReadingTableQuestionAnswer
|
||||
{
|
||||
public int ShowOrder { get; set; }
|
||||
}
|
||||
|
||||
public class TrialReadTableQuestion
|
||||
{
|
||||
public List<ReadingTableQuestionTrial> Questions { get; set; }
|
||||
|
||||
public List<Dictionary<Guid,string>> Answers { get; set; }
|
||||
}
|
||||
|
||||
public class GetReadingQuestionAndAnswerInDto
|
||||
{
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
public class GetHistoryGlobalInfoOutDto
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace IRaCIS.Application.Services
|
|||
// var readingTrialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.IsConfirm).FirstNotNullAsync();
|
||||
// List<GetTrialReadingQuestionOutDto> qusetionList = await GetReadingAnswerView(readingTrialCriterion.Id, inDto.VisitTaskId);
|
||||
|
||||
|
||||
|
||||
|
||||
// var groupList = qusetionList.Where(x => x.Type == "group" || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList();
|
||||
// groupList.ForEach(x =>
|
||||
|
@ -121,6 +121,143 @@ namespace IRaCIS.Application.Services
|
|||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取表格问题及答案(2022-08-26)
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<(GetReadingQuestionAndAnswerOutDto,object)> GetReadingQuestionAndAnswer(GetReadingQuestionAndAnswerInDto inDto)
|
||||
{
|
||||
|
||||
var readingTaskState = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.ReadingTaskState).FirstOrDefaultAsync();
|
||||
var criterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.IsConfirm).FirstNotNullAsync();
|
||||
|
||||
|
||||
var result = new GetReadingQuestionAndAnswerOutDto();
|
||||
|
||||
#region 获取问题及答案
|
||||
|
||||
var qusetionList = await _readingQuestionTrialRepository.Where(x=>x.ReadingQuestionCriterionTrialId== criterion.Id)
|
||||
.ProjectTo<TrialReadQuestionData>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
|
||||
|
||||
var answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync();
|
||||
|
||||
qusetionList.ForEach(x =>
|
||||
{
|
||||
x.Answer = answers.Where(y => y.ReadingQuestionTrialId == x.Id).Select(x => x.Answer).FirstOrDefault() ?? string.Empty;
|
||||
});
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
var formType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == criterion.Id).Select(x => x.FormType).FirstOrDefaultAsync();
|
||||
var groupList = new List<TrialReadQuestionData>();
|
||||
|
||||
var qusetionIds = qusetionList.Select(x => x.Id).ToList();
|
||||
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => qusetionIds.Contains(x.ReadingQuestionId))
|
||||
.OrderBy(x => x.ShowOrder).ToListAsync();
|
||||
|
||||
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository
|
||||
.ProjectTo<ReadingTableQuestionAnswerInfo>(_mapper.ConfigurationProvider)
|
||||
.Where(x => x.TaskId == inDto.VisitTaskId).ToListAsync();
|
||||
|
||||
|
||||
if (formType == FormType.MultiplePage)
|
||||
{
|
||||
qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId != null).ToList();
|
||||
var readingCriterionPageIds = qusetionList.OrderBy(x => x.PageShowOrder).Select(x => x.ReadingCriterionPageId).Distinct().ToList();
|
||||
foreach (var item in readingCriterionPageIds)
|
||||
{
|
||||
var newPageQusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == item).ToList();
|
||||
var firstData = newPageQusetionList.FirstOrDefault();
|
||||
var page = new TrialReadQuestionData()
|
||||
{
|
||||
PageName = firstData.PageName,
|
||||
IsPage = true,
|
||||
IsPublicPage = firstData.IsPublicPage,
|
||||
};
|
||||
|
||||
var pageGroupList = newPageQusetionList.Where(x => x.Type == "group" || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList();
|
||||
pageGroupList.ForEach(x =>
|
||||
{
|
||||
this.FindChildQuestion(x, newPageQusetionList, tableQuestionList, tableAnswers);
|
||||
});
|
||||
|
||||
page.Childrens = pageGroupList.Where(x => !(x.Type == "group" && x.Childrens.Count() == 0)).ToList();
|
||||
groupList.Add(page);
|
||||
}
|
||||
|
||||
result.PublicPage = groupList.Where(x => x.IsPublicPage.Value).ToList();
|
||||
result.MultiPage = groupList.Where(x => !x.IsPublicPage.Value).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
qusetionList = qusetionList.Where(x => x.ReadingCriterionPageId == null).ToList();
|
||||
|
||||
groupList = qusetionList.Where(x => x.Type == "group" || (x.ParentId == null && x.GroupName.IsNullOrEmpty())).ToList();
|
||||
groupList.ForEach(x =>
|
||||
{
|
||||
this.FindChildQuestion(x, qusetionList, tableQuestionList, tableAnswers);
|
||||
});
|
||||
|
||||
groupList = groupList.Where(x => !(x.Type == "group" && x.Childrens.Count() == 0)).ToList();
|
||||
|
||||
result.SinglePage = groupList;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return (result, new
|
||||
{
|
||||
readingTaskState = readingTaskState,
|
||||
FormType = formType
|
||||
|
||||
}); ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取子元素
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="questionlists"></param>
|
||||
/// <param name="tableQuestionLists"></param>
|
||||
public void FindChildQuestion(TrialReadQuestionData item, List<TrialReadQuestionData> questionlists, List<ReadingTableQuestionTrial> tableQuestionLists,List<ReadingTableQuestionAnswerInfo> tableAnswers)
|
||||
{
|
||||
item.Childrens = questionlists.Where(x => x.ParentId == item.Id || (item.Type == "group" && x.Type != "group" && x.ParentId == null && x.GroupName == item.GroupName)).ToList();
|
||||
item.TableQuestions = new TrialReadTableQuestion();
|
||||
|
||||
item.TableQuestions.Questions = tableQuestionLists.Where(x => x.ReadingQuestionId == item.Id).OrderBy(x=>x.ShowOrder).ToList();
|
||||
var thisAnswer = tableAnswers.Where(x => x.QuestionId == item.Id).ToList();
|
||||
var orders = thisAnswer.Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
|
||||
item.TableQuestions.Answers = new List<Dictionary<Guid, string>>();
|
||||
orders.ForEach(x =>
|
||||
{
|
||||
Dictionary<Guid, string> answers = new Dictionary<Guid, string>();
|
||||
var rowAnswer = thisAnswer.Where(y => y.RowIndex == x).OrderBy(y => y.ShowOrder).ToList();
|
||||
rowAnswer.ForEach(z =>
|
||||
{
|
||||
|
||||
answers.Add(z.TableQuestionId, z.Answer);
|
||||
});
|
||||
|
||||
item.TableQuestions.Answers.Add(answers);
|
||||
});
|
||||
|
||||
if (item.Childrens != null && item.Childrens.Count != 0)
|
||||
{
|
||||
item.Childrens.ForEach(x =>
|
||||
{
|
||||
this.FindChildQuestion(x, questionlists, tableQuestionLists, tableAnswers);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取关联的阅片任务
|
||||
/// </summary>
|
||||
|
@ -807,7 +944,7 @@ namespace IRaCIS.Application.Services
|
|||
readingTaskState = readingTaskState,
|
||||
FormType = formType
|
||||
|
||||
}); ;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -51,6 +51,14 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
#region 阅片问题
|
||||
|
||||
|
||||
CreateMap<ReadingTableQuestionAnswer, ReadingTableQuestionAnswerInfo>()
|
||||
.ForMember(d => d.ShowOrder, u => u.MapFrom(s => s.ReadingQuestionTrial.ShowOrder));
|
||||
|
||||
CreateMap<ReadingQuestionTrial, TrialReadQuestionData>()
|
||||
.ForMember(d => d.PageShowOrder, u => u.MapFrom(s => s.ReadingCriterionPage.ShowOrder))
|
||||
.ForMember(d => d.PageName, u => u.MapFrom(s => s.ReadingCriterionPage.PageName))
|
||||
.ForMember(d => d.IsPublicPage, u => u.MapFrom(s => s.ReadingCriterionPage.IsPublicPage));
|
||||
CreateMap<ReadingQuestionSystem, GetSystemReadingQuestionOutDto>();
|
||||
|
||||
CreateMap<ReadingTableQuestionSystem, TableQuestionDataInfo>();
|
||||
|
|
|
@ -241,6 +241,11 @@ namespace IRaCIS.Core.Domain.Share
|
|||
/// 是否淋巴结
|
||||
/// </summary>
|
||||
IsLymph = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 自增Id
|
||||
/// </summary>
|
||||
AutoId=3,
|
||||
}
|
||||
|
||||
public enum QuestionType
|
||||
|
|
|
@ -55,8 +55,12 @@ namespace IRaCIS.Core.Domain.Models
|
|||
/// 创建人
|
||||
/// </summary>
|
||||
public Guid CreateUserId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[ForeignKey("QuestionId")]
|
||||
|
||||
public ReadingQuestionTrial ReadingQuestionTrial { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue