Uat_Study
			
			
		
		
							parent
							
								
									1866257ff5
								
							
						
					
					
						commit
						38205b3b97
					
				| 
						 | 
				
			
			@ -11,6 +11,8 @@ using IRaCIS.Core.Application.Service.Reading.Dto;
 | 
			
		|||
using IRaCIS.Core.Infra.EFCore.Common;
 | 
			
		||||
using IRaCIS.Core.Domain.Share;
 | 
			
		||||
using MassTransit;
 | 
			
		||||
using IRaCIS.Core.Infrastructure;
 | 
			
		||||
using IRaCIS.Core.Domain.Models;
 | 
			
		||||
 | 
			
		||||
namespace IRaCIS.Core.Application.Service
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -38,6 +40,8 @@ namespace IRaCIS.Core.Application.Service
 | 
			
		|||
 | 
			
		||||
        private readonly IRepository<ClinicalTableAnswer> _clinicalTableAnswerRepository;
 | 
			
		||||
 | 
			
		||||
        private readonly IRepository<ClinicalAnswerRowInfo> _clinicalAnswerRowInfoRepository;
 | 
			
		||||
 | 
			
		||||
        private readonly IClinicalQuestionService _iClinicalQuestionService;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -48,10 +52,12 @@ namespace IRaCIS.Core.Application.Service
 | 
			
		|||
            IRepository<ClinicalTableAnswer> clinicalTableAnswerRepository,
 | 
			
		||||
             IRepository<ClinicalQuestionAnswer> clinicalQuestionAnswerRepository,
 | 
			
		||||
                IClinicalQuestionService iClinicalQuestionService,
 | 
			
		||||
            IRepository<ClinicalDataTrialSet> clinicalDataTrialSetRepository,
 | 
			
		||||
                IRepository<ClinicalAnswerRowInfo> clinicalAnswerRowInfoRepository,
 | 
			
		||||
        IRepository<ClinicalDataTrialSet> clinicalDataTrialSetRepository,
 | 
			
		||||
            IRepository<SystemClinicalQuestion> systemClinicalQuestionRepository
 | 
			
		||||
            )
 | 
			
		||||
        {
 | 
			
		||||
            _clinicalAnswerRowInfoRepository = clinicalAnswerRowInfoRepository;
 | 
			
		||||
            _clinicalQuestionAnswerRepository = clinicalQuestionAnswerRepository;
 | 
			
		||||
            _systemClinicalTableQuestionRepository = systemClinicalTableQuestionRepository;
 | 
			
		||||
            _trialClinicalQuestionRepository = trialClinicalQuestionRepository;
 | 
			
		||||
| 
						 | 
				
			
			@ -130,6 +136,7 @@ namespace IRaCIS.Core.Application.Service
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="inDto"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<GetClinicalFormInfoOutDto> GetClinicalFormInfo(GetClinicalFormInfoInDto inDto)
 | 
			
		||||
        {
 | 
			
		||||
            var formInfo = await _clinicalFormRepository.Where(x => x.Id == inDto.ClinicalFormId).FirstNotNullAsync();
 | 
			
		||||
| 
						 | 
				
			
			@ -176,9 +183,90 @@ namespace IRaCIS.Core.Application.Service
 | 
			
		|||
        /// </summary>
 | 
			
		||||
        /// <param name="inDto"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task SubmitClinicalForm(SubmitClinicalFormInDto inDto)
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
        public async Task<IResponseOutput> SubmitClinicalForm(SubmitClinicalFormInDto inDto)
 | 
			
		||||
        {
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            var checkDateQuestionId = await _trialClinicalQuestionRepository.Where(x => x.TrialClinicalId == inDto.ClinicalDataTrialSetId && x.IsCheckDate).Select(x => x.Id).FirstNotNullAsync();
 | 
			
		||||
            ClinicalForm clinicalForm = new ClinicalForm() { };
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                clinicalForm = new ClinicalForm()
 | 
			
		||||
                {
 | 
			
		||||
                    ClinicalDataTrialSetId = inDto.ClinicalDataTrialSetId,
 | 
			
		||||
                    SubjectId = inDto.SubjectId,
 | 
			
		||||
                    Id = inDto.ClinicalFormId ?? NewId.NextGuid(),
 | 
			
		||||
                    ReadingId=inDto.ReadingId,
 | 
			
		||||
                    VisitId=inDto.VisitId,
 | 
			
		||||
                    CheckDate = DateTime.Parse(inDto.QuestionAnswers.Where(x => x.QuestionId == checkDateQuestionId).Select(x => x.Answer).First()),
 | 
			
		||||
                };
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception)
 | 
			
		||||
            {
 | 
			
		||||
                throw new BusinessValidationFailedException("检查日期问题答案填写错误!");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            List<ClinicalQuestionAnswer> clinicalQuestionAnswers = inDto.QuestionAnswers.Select(x => new ClinicalQuestionAnswer()
 | 
			
		||||
            {
 | 
			
		||||
                Answer=x.Answer,
 | 
			
		||||
                ClinicalDataTrialSetId=inDto.ClinicalDataTrialSetId,
 | 
			
		||||
                SubjectId=inDto.SubjectId,
 | 
			
		||||
                ClinicalFormId= clinicalForm.Id,
 | 
			
		||||
                QuestionId=x.QuestionId,
 | 
			
		||||
            }).ToList();
 | 
			
		||||
 | 
			
		||||
            List<ClinicalAnswerRowInfo> clinicalAnswerRowInfos = new List<ClinicalAnswerRowInfo>();
 | 
			
		||||
 | 
			
		||||
            List<ClinicalTableAnswer> clinicalTableAnswers = new List<ClinicalTableAnswer>();
 | 
			
		||||
 | 
			
		||||
            inDto.TableQuestionAnswerList.ForEach(x => {
 | 
			
		||||
                var questionid = x.QuestionId;
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < x.TableQuestionAnswers.Count(); i++)
 | 
			
		||||
                {
 | 
			
		||||
                    var rowInfo = new ClinicalAnswerRowInfo()
 | 
			
		||||
                    {
 | 
			
		||||
                        Id = NewId.NextGuid(),
 | 
			
		||||
                        SubjectId = inDto.SubjectId,
 | 
			
		||||
                        ClinicalFormId = clinicalForm.Id,
 | 
			
		||||
                        QuestionId = questionid,
 | 
			
		||||
                        RowIndex = i+1,
 | 
			
		||||
                    };
 | 
			
		||||
                    clinicalAnswerRowInfos.Add(rowInfo);
 | 
			
		||||
 | 
			
		||||
                    x.TableQuestionAnswers[i].ForEach(y => {
 | 
			
		||||
 | 
			
		||||
                        clinicalTableAnswers.Add(new ClinicalTableAnswer()
 | 
			
		||||
                        {
 | 
			
		||||
                            Answer=y.Answer,
 | 
			
		||||
                            ClinicalFormId= clinicalForm.Id,
 | 
			
		||||
                            QuestionId= questionid,
 | 
			
		||||
                            RowId= rowInfo.Id,
 | 
			
		||||
                            TableQuestionId=y.TableQuestionId,
 | 
			
		||||
                            SubjectId= inDto.SubjectId,
 | 
			
		||||
                           
 | 
			
		||||
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                   });
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            if (inDto.ClinicalFormId != null)
 | 
			
		||||
            {
 | 
			
		||||
                await _clinicalFormRepository.BatchDeleteNoTrackingAsync(x => x.Id == inDto.ClinicalFormId);
 | 
			
		||||
                await _clinicalQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.ClinicalFormId == inDto.ClinicalFormId);
 | 
			
		||||
                await _clinicalAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.ClinicalFormId == inDto.ClinicalFormId);
 | 
			
		||||
                await _clinicalTableAnswerRepository.BatchDeleteNoTrackingAsync(x => x.ClinicalFormId == inDto.ClinicalFormId);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            await _clinicalFormRepository.AddAsync(clinicalForm);
 | 
			
		||||
            await _clinicalQuestionAnswerRepository.AddRangeAsync(clinicalQuestionAnswers);
 | 
			
		||||
            await _clinicalAnswerRowInfoRepository.AddRangeAsync(clinicalAnswerRowInfos);
 | 
			
		||||
            await _clinicalTableAnswerRepository.AddRangeAsync(clinicalTableAnswers);
 | 
			
		||||
            await _clinicalTableAnswerRepository.SaveChangesAsync();
 | 
			
		||||
            return ResponseOutput.Ok(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,6 +71,16 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
 | 
			
		|||
 | 
			
		||||
    public class SubmitClinicalFormInDto
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// VisitId
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Guid? VisitId { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// VisitId
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Guid? ReadingId { get; set; }
 | 
			
		||||
 | 
			
		||||
        public Guid? ClinicalFormId { get; set; }
 | 
			
		||||
 | 
			
		||||
        public Guid SubjectId { get; set; }
 | 
			
		||||
| 
						 | 
				
			
			@ -80,6 +90,22 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
 | 
			
		|||
 | 
			
		||||
        public List<ClinicalFormQuestionAnswer> QuestionAnswers { get; set; }
 | 
			
		||||
 | 
			
		||||
        public List<List<ClinicalFormQuestionAnswer>> TableQuestionAnswer { get; set; }
 | 
			
		||||
        public List<ClinicalQuestionForm> TableQuestionAnswerList { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public class ClinicalQuestionForm
 | 
			
		||||
    {
 | 
			
		||||
        public Guid QuestionId { get; set; }
 | 
			
		||||
 | 
			
		||||
        public List<List<ClinicalTableQuestionForm>> TableQuestionAnswers { get; set; }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public class ClinicalTableQuestionForm
 | 
			
		||||
    {
 | 
			
		||||
        public Guid TableQuestionId { get; set; }
 | 
			
		||||
 | 
			
		||||
        public string Answer { get; set; } = string.Empty;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,7 +40,17 @@ namespace IRaCIS.Core.Domain.Models
 | 
			
		|||
        /// ClinicalDataTrialSetId
 | 
			
		||||
        /// </summary>
 | 
			
		||||
		public Guid ClinicalDataTrialSetId { get; set; }
 | 
			
		||||
	 
 | 
			
		||||
	 }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// VisitId
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Guid? VisitId { get; set; }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// VisitId
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public Guid? ReadingId { get; set; }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}	 
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue