Uat_Study
hang 2022-10-17 15:02:27 +08:00
parent fde24002d1
commit a1913ca5b3
6 changed files with 152 additions and 126 deletions

View File

@ -204,6 +204,7 @@ namespace IRaCIS.Core.Application.Service
}
#region 问题
private async Task<List<ReadingMedicineQuestion>> GetMedicalQuestionAnswer(GetMedicalReviewReadingTaskInDto inDto)
{
var medicalReview = await _taskMedicalReviewRepository.Where(x => x.Id == inDto.TaskMedicalReviewId).FirstNotNullAsync();
@ -250,6 +251,7 @@ namespace IRaCIS.Core.Application.Service
});
}
}
#endregion

View File

@ -1,7 +1,4 @@
using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Infra.EFCore.Common;
using MassTransit;
@ -37,6 +34,9 @@ namespace IRaCIS.Core.Application.Service
}
#region 系统
/// <summary>
/// 获取系统的医学审核问题
/// </summary>
@ -105,9 +105,6 @@ namespace IRaCIS.Core.Application.Service
return ResponseOutput.Ok(entity.Id.ToString());
}
/// <summary>
/// 删除系统的医学审核问题
/// </summary>
@ -124,8 +121,11 @@ namespace IRaCIS.Core.Application.Service
var result = await _readingMedicineSystemQuestionRepository.SaveChangesAsync();
return ResponseOutput.Result(result);
}
#endregion
#region 项目
/// <summary>
/// 获取项目的医学审核问题
/// </summary>
/// <param name="inDto"></param>
@ -145,67 +145,14 @@ namespace IRaCIS.Core.Application.Service
var isConfirmMedicineQuestion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).Select(x => x.IsConfirmMedicineQuestion).FirstOrDefaultAsync();
var questionList = await query.ToListAsync();
return (questionList, new {
return (questionList, new
{
IsConfirmMedicineQuestion = isConfirmMedicineQuestion,
QuestionCount = questionList.Count(),
});
}
/// <summary>
/// 获取预览问题信息
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<List<GetMedicineQuestionPreviewOutDto>> GetMedicineQuestionPreview(GetMedicineQuestionPreviewInDto inDto)
{
var trialQuestionList = await _readingMedicineTrialQuestionRepository.Where(x=>x.TrialId==inDto.TrialId&&x.TrialReadingCriterionId==inDto.TrialReadingCriterionId)
.WhereIf(inDto.ReadingCategory != null, x => x.ReadingCategory == inDto.ReadingCategory)
.ProjectTo<GetMedicineQuestionPreviewOutDto>(_mapper.ConfigurationProvider).OrderBy(x=>x.ShowOrder).ToListAsync();
List<GetMedicineQuestionPreviewOutDto> readingQuestionList = trialQuestionList.Where(x => x.ParentId == null).ToList();
readingQuestionList.ForEach(x =>
{
FindChildQuestion(x, trialQuestionList);
});
return readingQuestionList;
}
private void FindChildQuestion(GetMedicineQuestionPreviewOutDto trialReadingQuestion, List<GetMedicineQuestionPreviewOutDto> questionlists)
{
trialReadingQuestion.Childrens = questionlists.Where(x => x.ParentId == trialReadingQuestion.Id).ToList();
if (trialReadingQuestion.Childrens != null && trialReadingQuestion.Childrens.Count != 0)
{
trialReadingQuestion.Childrens.ForEach(x =>
{
this.FindChildQuestion(x, questionlists);
});
}
}
/// <summary>
/// 新增或修改项目医学审核问题
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateReadingMedicineTrialQuestion(ReadingMedicineTrialQuestionAddOrEdit inDto)
{
var existsQuery = _readingMedicineTrialQuestionRepository
.WhereIf(inDto.Id != null, x => x.Id != inDto.Id)
.Where(x => x.TrialId==inDto.TrialId&&x.TrialReadingCriterionId==inDto.TrialReadingCriterionId)
.Where(x => x.ShowOrder == inDto.ShowOrder);
if (await existsQuery.AnyAsync())
{
return ResponseOutput.NotOk("当前问题序号存在重复");
}
var entity = await _readingMedicineTrialQuestionRepository.InsertOrUpdateAsync(inDto);
await _readingMedicineTrialQuestionRepository.SaveChangesAsync();
return ResponseOutput.Ok(entity.Id.ToString());
}
/// <summary>
/// 获取项目的其他医学审核问题
@ -237,57 +184,48 @@ namespace IRaCIS.Core.Application.Service
}
/// <summary>
/// 从系统里面选择问题添加到项目里面
/// <summary>
/// 获取预览问题信息
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddTrialDataFromSystem(AddTrialDataFromSystemInDto inDto)
public async Task<List<GetMedicineQuestionPreviewOutDto>> GetMedicineQuestionPreview(GetMedicineQuestionPreviewInDto inDto)
{
// 直接写??
var systemList = await _readingMedicineSystemQuestionRepository.Where(x => inDto.SystemQuestionIds.Contains(x.Id)).ToListAsync();
var trialQuestionList = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId)
.WhereIf(inDto.ReadingCategory != null, x => x.ReadingCategory == inDto.ReadingCategory)
.ProjectTo<GetMedicineQuestionPreviewOutDto>(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync();
var maxOrder = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId).OrderByDescending(x => x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync();
var needList= systemList.Select(x => new TrialDataFromSystem()
List<GetMedicineQuestionPreviewOutDto> readingQuestionList = trialQuestionList.Where(x => x.ParentId == null).ToList();
readingQuestionList.ForEach(x =>
{
Id = NewId.NextGuid(),
ShowOrder = x.ShowOrder,
IsEnable = x.IsEnable,
IsRequired = x.IsRequired,
QuestionName = x.QuestionName,
TrialReadingCriterionId=inDto.TrialReadingCriterionId,
Type = x.Type,
ParentId=x.ParentId,
SystemQuestionId=x.Id,
ReadingCategory=x.ReadingCategory,
TypeValue = x.TypeValue,
TrialId=inDto.TrialId,
}).ToList();
needList.ForEach(x => {
maxOrder++;
x.ShowOrder = maxOrder;
FindChildQuestion(x, trialQuestionList);
});
foreach (var item in needList.Where(x => x.ParentId != null))
{
var parent = needList.Where(x => x.SystemQuestionId == item.ParentId).FirstOrDefault();
if (parent == null)
{
item.ParentId = null;
item.ParentTriggerValue = String.Empty;
}
else
{
item.ParentId = parent.Id;
}
return readingQuestionList;
}
await _readingMedicineTrialQuestionRepository.AddRangeAsync(needList);
var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync();
return ResponseOutput.Result(result);
/// <summary>
/// 新增或修改项目医学审核问题
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddOrUpdateReadingMedicineTrialQuestion(ReadingMedicineTrialQuestionAddOrEdit inDto)
{
var existsQuery = _readingMedicineTrialQuestionRepository
.WhereIf(inDto.Id != null, x => x.Id != inDto.Id)
.Where(x => x.TrialId == inDto.TrialId && x.TrialReadingCriterionId == inDto.TrialReadingCriterionId)
.Where(x => x.ShowOrder == inDto.ShowOrder);
if (await existsQuery.AnyAsync())
{
return ResponseOutput.NotOk("当前问题序号存在重复");
}
var entity = await _readingMedicineTrialQuestionRepository.InsertOrUpdateAsync(inDto);
await _readingMedicineTrialQuestionRepository.SaveChangesAsync();
return ResponseOutput.Ok(entity.Id.ToString());
}
/// <summary>
@ -308,6 +246,16 @@ namespace IRaCIS.Core.Application.Service
}
#endregion
#region 项目 医学审核问题 验证 确认
/// <summary>
/// 验证医学审核问题
/// </summary>
@ -443,6 +391,82 @@ namespace IRaCIS.Core.Application.Service
}
#endregion
private void FindChildQuestion(GetMedicineQuestionPreviewOutDto trialReadingQuestion, List<GetMedicineQuestionPreviewOutDto> questionlists)
{
trialReadingQuestion.Childrens = questionlists.Where(x => x.ParentId == trialReadingQuestion.Id).ToList();
if (trialReadingQuestion.Childrens != null && trialReadingQuestion.Childrens.Count != 0)
{
trialReadingQuestion.Childrens.ForEach(x =>
{
this.FindChildQuestion(x, questionlists);
});
}
}
/// <summary>
/// 从系统里面选择问题添加到项目里面
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> AddTrialDataFromSystem(AddTrialDataFromSystemInDto inDto)
{
// 直接写??
var systemList = await _readingMedicineSystemQuestionRepository.Where(x => inDto.SystemQuestionIds.Contains(x.Id)).ToListAsync();
var maxOrder = await _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId).OrderByDescending(x => x.ShowOrder).Select(x => x.ShowOrder).FirstOrDefaultAsync();
var needList= systemList.Select(x => new TrialDataFromSystem()
{
Id = NewId.NextGuid(),
ShowOrder = x.ShowOrder,
IsEnable = x.IsEnable,
IsRequired = x.IsRequired,
QuestionName = x.QuestionName,
TrialReadingCriterionId=inDto.TrialReadingCriterionId,
Type = x.Type,
ParentId=x.ParentId,
SystemQuestionId=x.Id,
ReadingCategory=x.ReadingCategory,
TypeValue = x.TypeValue,
TrialId=inDto.TrialId,
}).ToList();
needList.ForEach(x => {
maxOrder++;
x.ShowOrder = maxOrder;
});
foreach (var item in needList.Where(x => x.ParentId != null))
{
var parent = needList.Where(x => x.SystemQuestionId == item.ParentId).FirstOrDefault();
if (parent == null)
{
item.ParentId = null;
item.ParentTriggerValue = String.Empty;
}
else
{
item.ParentId = parent.Id;
}
}
await _readingMedicineTrialQuestionRepository.AddRangeAsync(needList);
var result = await _readingMedicineTrialQuestionRepository.SaveChangesAsync();
return ResponseOutput.Result(result);
}
}