脾脏验证
							parent
							
								
									f5885f612a
								
							
						
					
					
						commit
						0820cffd9d
					
				| 
						 | 
				
			
			@ -2586,34 +2586,34 @@ namespace IRaCIS.Application.Services
 | 
			
		|||
            else
 | 
			
		||||
            {
 | 
			
		||||
                #region 两小时
 | 
			
		||||
                //var cacheDate = DateTime.Parse(value.ToString());
 | 
			
		||||
                //int timespanMin = (DateTime.Now - cacheDate).Minutes;
 | 
			
		||||
                //if (timespanMin > 120 && timespanMin < 130)
 | 
			
		||||
                //{
 | 
			
		||||
                //    throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", 2, 20]);
 | 
			
		||||
                //}
 | 
			
		||||
                //else if (timespanMin > 130)
 | 
			
		||||
                //{
 | 
			
		||||
                //    cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 130))) * 130);
 | 
			
		||||
                //    _provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
                //   // _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
                var cacheDate = DateTime.Parse(value.ToString());
 | 
			
		||||
                int timespanMin = (DateTime.Now - cacheDate).Minutes;
 | 
			
		||||
                if (timespanMin > 120 && timespanMin < 130)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", 2, 10]);
 | 
			
		||||
                }
 | 
			
		||||
                else if (timespanMin > 130)
 | 
			
		||||
                {
 | 
			
		||||
                    cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 130))) * 130);
 | 
			
		||||
                    _provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
                    // _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
 | 
			
		||||
                //}
 | 
			
		||||
                }
 | 
			
		||||
                #endregion
 | 
			
		||||
 | 
			
		||||
                #region 测试用的5分钟
 | 
			
		||||
                var cacheDate = DateTime.Parse(value.ToString());
 | 
			
		||||
                int timespanMin = (DateTime.Now - cacheDate).Minutes;
 | 
			
		||||
                if (timespanMin >= 1 && timespanMin <= 100)
 | 
			
		||||
                {
 | 
			
		||||
                    throw new BusinessValidationFailedException("您已连续阅片2个小时,请休息20分钟后,再继续阅片。");
 | 
			
		||||
                }
 | 
			
		||||
                else if (timespanMin > 10)
 | 
			
		||||
                {
 | 
			
		||||
                    cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 10))) * 10);
 | 
			
		||||
					_provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
                //var cacheDate = DateTime.Parse(value.ToString());
 | 
			
		||||
                //int timespanMin = (DateTime.Now - cacheDate).Minutes;
 | 
			
		||||
                //if (timespanMin >= 5 && timespanMin <= 10)
 | 
			
		||||
                //{
 | 
			
		||||
                //    throw new BusinessValidationFailedException("您已连续阅片2个小时,请休息20分钟后,再继续阅片。");
 | 
			
		||||
                //}
 | 
			
		||||
                //else if (timespanMin > 10)
 | 
			
		||||
                //{
 | 
			
		||||
                //    cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 10))) * 10);
 | 
			
		||||
                //    _provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5));
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                //}
 | 
			
		||||
                #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ using IRaCIS.Core.Infrastructure;
 | 
			
		|||
using MassTransit;
 | 
			
		||||
using System.Reflection.Metadata.Ecma335;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using NPOI.SS.Formula.Functions;
 | 
			
		||||
 | 
			
		||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -1769,36 +1770,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
 | 
			
		|||
                }
 | 
			
		||||
            
 | 
			
		||||
            }
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
            #region 最低
 | 
			
		||||
            var visitTaskIds = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
 | 
			
		||||
              x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
 | 
			
		||||
              x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
 | 
			
		||||
               x.DoctorUserId == taskinfo.DoctorUserId &&
 | 
			
		||||
               x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
 | 
			
		||||
              x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
 | 
			
		||||
              && x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect
 | 
			
		||||
              ).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).ToListAsync();
 | 
			
		||||
 | 
			
		||||
            var questionId = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.QuestionType == QuestionType.SpleenLength).Select(x => x.Id).FirstNotNullAsync();
 | 
			
		||||
            var answerList = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)
 | 
			
		||||
              && x.ReadingQuestionTrialId == questionId )
 | 
			
		||||
                  .Select(x => new
 | 
			
		||||
                  {
 | 
			
		||||
                      x.Answer,
 | 
			
		||||
                      x.VisitTaskId,
 | 
			
		||||
                  }).ToListAsync();
 | 
			
		||||
 | 
			
		||||
            var lowSpleenLength = answerList.Select(x => new
 | 
			
		||||
            {
 | 
			
		||||
                Answer = x.Answer.IsNullOrEmptyReturn0(),
 | 
			
		||||
                x.VisitTaskId
 | 
			
		||||
            }).OrderBy(x => x.Answer).Select(x=>x.Answer).FirstOrDefault();
 | 
			
		||||
            #endregion
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var result = SpleenAssessment.Stabilization;
 | 
			
		||||
			var lowSpleenLength = await this.GetLowSpleenLength(taskinfo);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			var result = SpleenAssessment.Stabilization;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var presentSpd = spleenLength;
 | 
			
		||||
| 
						 | 
				
			
			@ -1857,15 +1834,97 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
 | 
			
		|||
            return result.GetEnumInt();
 | 
			
		||||
        }
 | 
			
		||||
        #endregion
 | 
			
		||||
        
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取最低垂直径
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        private async Task<decimal> GetLowSpleenLength(VisitTask taskinfo)
 | 
			
		||||
        {
 | 
			
		||||
			var visitTaskIds = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
 | 
			
		||||
			x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
 | 
			
		||||
			x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
 | 
			
		||||
			 x.DoctorUserId == taskinfo.DoctorUserId &&
 | 
			
		||||
			 x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
 | 
			
		||||
			x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
 | 
			
		||||
			&& x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect
 | 
			
		||||
			).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).ToListAsync();
 | 
			
		||||
 | 
			
		||||
        #region 获取脾脏评估
 | 
			
		||||
			var questionId = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.QuestionType == QuestionType.SpleenLength).Select(x => x.Id).FirstNotNullAsync();
 | 
			
		||||
			var answerList = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)
 | 
			
		||||
			  && x.ReadingQuestionTrialId == questionId)
 | 
			
		||||
				  .Select(x => new
 | 
			
		||||
				  {
 | 
			
		||||
					  x.Answer,
 | 
			
		||||
					  x.VisitTaskId,
 | 
			
		||||
				  }).ToListAsync();
 | 
			
		||||
 | 
			
		||||
			var lowSpleenLength = answerList.Select(x => new
 | 
			
		||||
			{
 | 
			
		||||
				Answer = x.Answer.IsNullOrEmptyReturn0(),
 | 
			
		||||
				x.VisitTaskId
 | 
			
		||||
			}).OrderBy(x => x.Answer).Select(x => x.Answer).FirstOrDefault();
 | 
			
		||||
 | 
			
		||||
            return lowSpleenLength;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 获取脾脏评估
 | 
			
		||||
        /// 获取脾脏验证
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="inDto"></param>
 | 
			
		||||
        /// <param name="visitTaskId"></param>
 | 
			
		||||
        /// <param name="spleenLength"></param>
 | 
			
		||||
        /// <returns></returns>
 | 
			
		||||
        public async Task<string> GetSplenicEvaluation(ReadingCalculateDto inDto)
 | 
			
		||||
        [HttpPost]
 | 
			
		||||
		public async Task<object> GetSplenicVerify(Guid visitTaskId, decimal spleenLength)
 | 
			
		||||
        {
 | 
			
		||||
			var presentSpd = spleenLength;
 | 
			
		||||
			ReadingCalculateDto inDto = await _generalCalculateService.GetReadingCalculateDto(visitTaskId);
 | 
			
		||||
 | 
			
		||||
			// 基线垂直径
 | 
			
		||||
			var baseLineSpleenLength = await GetBaseLineSpleenLength(inDto);
 | 
			
		||||
 | 
			
		||||
			var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
 | 
			
		||||
 | 
			
		||||
			var differenceValue = presentSpd - baseLineSpleenLength;
 | 
			
		||||
 | 
			
		||||
			//与基线相比脾肿大增加的百分比
 | 
			
		||||
			decimal percentage = 0;
 | 
			
		||||
			if (baseLineSpleenLength != 0)
 | 
			
		||||
			{
 | 
			
		||||
				percentage = differenceValue * 100 / (baseLineSpleenLength - 130);
 | 
			
		||||
			}
 | 
			
		||||
			var baseLineTaskId = await GetBaseLineTaskId(inDto);
 | 
			
		||||
 | 
			
		||||
			// 最低垂直经
 | 
			
		||||
			var lowSpleenLength= await this.GetLowSpleenLength(taskinfo);
 | 
			
		||||
 | 
			
		||||
            // 基线状态
 | 
			
		||||
			var baseLineState = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SplenicStatus).Select(x => x.Answer).FirstOrDefaultAsync();
 | 
			
		||||
 | 
			
		||||
            return new
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
                //基线垂直径
 | 
			
		||||
                BaseLineSpleenLength = baseLineSpleenLength,
 | 
			
		||||
                //与基线相比脾肿大增加的百分比
 | 
			
		||||
                PercentageIncreaseFromBaseline = percentage,
 | 
			
		||||
                // 最低垂直经
 | 
			
		||||
                LowSpleenLength = lowSpleenLength,
 | 
			
		||||
                // 基线状态
 | 
			
		||||
                BaseLineState = baseLineState,
 | 
			
		||||
            };
 | 
			
		||||
           
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		#region 获取脾脏评估
 | 
			
		||||
 | 
			
		||||
		/// <summary>
 | 
			
		||||
		/// 获取脾脏评估
 | 
			
		||||
		/// </summary>
 | 
			
		||||
		/// <param name="inDto"></param>
 | 
			
		||||
		/// <returns></returns>
 | 
			
		||||
		public async Task<string> GetSplenicEvaluation(ReadingCalculateDto inDto)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
             return inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.SplenicStatus).Select(x => x.Answer).FirstIsNullReturnEmpty();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue