diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
index e48f4e24e..b472d798a 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
@@ -9,12 +9,56 @@ using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Service.Reading.Dto
{
#region 阅片问题
-
+
+
+ public class ReadingReportDto
+ {
+ public Guid Id
+ {
+ get
+ {
+ return new Guid();
+ }
+ }
+
+ public Guid QuestionId { get; set; }
+
+ public Guid TableQuestionId { get; set; }
+
+ public int ShowOrder { get; set; }
+
+ public int RowIndex { get; set; }
+
+ public string GroupName { get; set; }
+
+ public string QuestionName { get; set; }
+
+ ///
+ /// 序号标记
+ ///
+ public string OrderMark { get; set; } = string.Empty;
+
+ public List Answer { get; set; } = new List();
+
+ public List Childrens { get; set; } = new List();
+ }
+
+
+ public class TaskQuestionAnswer
+ {
+ public string TaskName { get; set; }
+
+ public Guid VisitTaskId { get; set; }
+
+ public string Answer { get; set; }
+ }
+
+
public class GetReadingReportEvaluationOutDto
{
public List VisitTaskList { get; set; }
- public List TaskQuestions { get; set; }
+ public List TaskQuestions { get; set; }
}
public class VisitTaskGroupAnswerDto
@@ -29,8 +73,6 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public Guid QuestionId { get; set; }
-
-
public string QuestionName { get; set; }
public string GroupName { get; set; }
diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
index e0827eeda..ae0042ef5 100644
--- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
+++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
@@ -136,7 +136,7 @@ namespace IRaCIS.Application.Services
var criterionId = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == indto.TrialId && x.IsConfirm).Select(x => x.Id).FirstOrDefaultAsync();
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ToListAsync();
- var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).ToListAsync();
+ var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x=>x.ShowOrder).ToListAsync();
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
@@ -146,7 +146,7 @@ namespace IRaCIS.Application.Services
// 第一级
#region 构造问题
- List questions = questionList.Where(x => x.Type == "group").OrderBy(x => x.ShowOrder).Select(x => new VisitTaskGroupInfo()
+ List questions = questionList.Where(x => x.Type == "group").OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
{
QuestionId = x.Id,
GroupName = x.GroupName,
@@ -154,88 +154,88 @@ namespace IRaCIS.Application.Services
ShowOrder = x.ShowOrder,
}).ToList();
+ // 分组
foreach (var item in questions)
{
- item.QuestionList = questionList.Where(x => x.GroupName == item.GroupName).OrderBy(x => x.ShowOrder).Select(x => new VisitTaskQuestionInfo()
+ item.Childrens = questionList.Where(x => x.GroupName == item.GroupName&&x.Type!= "group").OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
{
GroupName = x.GroupName,
QuestionId = x.Id,
QuestionName = x.QuestionName,
ShowOrder = x.ShowOrder,
+ OrderMark=x.OrderMark,
}).ToList();
- foreach (var question in item.QuestionList)
+ // 问题
+ foreach (var question in item.Childrens)
{
- question.TableRowQuestionList = new List()
- {
- };
- VistTaskTableQuestionRowInfo questionInfo = new VistTaskTableQuestionRowInfo()
+
+ foreach (var task in taskInfoList)
{
- RowIndex = 0,
- OrderMark = string.Empty,
- TableQuestionList = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new VistTaskTableQuestionInfo()
+ question.Answer.Add(new TaskQuestionAnswer()
+ {
+ Answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(),
+ TaskName = task.TaskName,
+ VisitTaskId = task.VisitTaskId,
+ });
+ }
+
+ // 构造表格行数据
+ var rowIndexs = tableAnswers.Where(x => x.QuestionId == question.QuestionId).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList();
+
+ question.Childrens = rowIndexs.Select(x => new ReadingReportDto()
+ {
+
+ QuestionName = question.OrderMark + x.ToString().PadLeft(2, '0'),
+ RowIndex=x,
+
+ }).ToList();
+
+
+ foreach (var row in question.Childrens)
+ {
+ // tableQuestion
+ row.Childrens = tableQuestionList.Select(x => new ReadingReportDto()
{
- Answer = string.Empty,
- QuestionId = question.QuestionId,
- TableQuestionId = x.Id,
- ShowOrder = x.ShowOrder,
QuestionName = x.QuestionName,
+ QuestionId = x.ReadingQuestionId,
+ TableQuestionId = x.Id,
+ RowIndex = row.RowIndex,
+ ShowOrder = x.ShowOrder,
- }).ToList()
+ }).ToList();
- };
- question.TableRowQuestionList.Add(questionInfo);
-
- }
- }
- #endregion
-
- #region 构造答案
-
- result.TaskQuestions = new List();
- foreach (var item in taskInfoList)
- {
- var itemQuestions = questions.Clone();
- foreach (var group in itemQuestions)
- {
- group.QuestionList.ForEach(x =>
- {
- x.Answer = answers.Where(n => n.VisitTaskId == item.VisitTaskId && x.QuestionId == x.QuestionId).Select(x => x.Answer).FirstOrDefault() ?? String.Empty;
- var tableQuestionAnswers = tableAnswers.Where(n => n.QuestionId == n.QuestionId && n.VisitTaskId == item.VisitTaskId).GroupBy(y => new { y.RowIndex }).Select(y => new
+ foreach (var tableQuestion in row.Childrens)
{
- RowIndex = y.Key.RowIndex,
- Answer = y.ToList(),
- });
- List questionRowInfos = new List();
- var answerModel = x.TableRowQuestionList.FirstOrDefault() ?? new VistTaskTableQuestionRowInfo();
- tableQuestionAnswers.ForEach(y =>
- {
- VistTaskTableQuestionRowInfo rowInfo = answerModel.Clone();
- rowInfo.RowIndex = y.RowIndex;
- rowInfo.TableQuestionList.ForEach(z =>
+ foreach (var task in taskInfoList)
{
- z.Answer = y.Answer.Where(n => n.TableQuestionId == z.TableQuestionId && n.QuestionId == z.QuestionId).Select(n => n.Answer).FirstOrDefault() ?? String.Empty;
- });
- questionRowInfos.Add(rowInfo);
- });
+ tableQuestion.Answer.Add(new TaskQuestionAnswer()
+ {
+ Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.TableQuestionId == tableQuestion.QuestionId&&x.RowIndex==tableQuestion.RowIndex&&x.TableQuestionId== tableQuestion.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(),
+ TaskName = task.TaskName,
+ VisitTaskId = task.VisitTaskId,
+ });
+ }
+ }
- x.TableRowQuestionList = questionRowInfos;
+
+ }
- });
- }
-
- result.TaskQuestions.Add(new VisitTaskGroupAnswerDto() {
-
- VisitTaskId=item.VisitTaskId,
- Questions= itemQuestions
- });
+
+ };
}
#endregion
+
+
+ result.TaskQuestions = questions;
+
+
+
return result;
}
diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs
index 1ec3f7336..f5e9f8b00 100644
--- a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs
+++ b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs
@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
+using System.Collections.Generic;
namespace IRaCIS.Core.Infrastructure.Extention
{
@@ -29,6 +30,25 @@ namespace IRaCIS.Core.Infrastructure.Extention
}
}
+ ///
+ /// 查询字符串 为null 返回string.Empty
+ ///
+ ///
+ ///
+ ///
+ public static string FirstIsNullReturnEmpty(this IEnumerable source)
+ {
+ var result = source.FirstOrDefault();
+
+ if (result == null || result == string.Empty)
+ {
+ return string.Empty;
+ }
+ else
+ {
+ return result;
+ }
+ }
}
}