diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs index 19b0d7c54..24d66c4a8 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalAnswerService.cs @@ -408,56 +408,94 @@ namespace IRaCIS.Core.Application.Service [HttpPost] public async Task> GetCRCConfirmList(GetCRCConfirmListInDto inDto) { - - List result = await _readModuleRepository.Where(x => x.TrialId == inDto.TrialId) - .Select(x => new GetCRCConfirmListOutDto() - { - IsCRCConfirm = x.IsCRCConfirm, - LatestScanDate = x.SubjectVisit.LatestScanDate, - ReadingSetType = x.ReadingSetType, - IsPMConfirm = x.IsPMConfirm, - ReadModuleId=x.Id, - - }).OrderBy(x => x.LatestScanDate).ToListAsync(); - - var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId) - .Where(x=> x.ClinicalDataTrialSet.UploadRole==UploadRole.CRC) - .Where(x=> x.ClinicalDataTrialSet.ClinicalDataLevel==ClinicalLevel.ImageRead|| x.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.OncologyRead) - .Select(x =>new CRCConfirmFormList - { - CkeckDate=x.CheckDate, - ClinicalDataLevel= x.ClinicalDataTrialSet.ClinicalDataLevel, - - - }).ToListAsync(); - - var confirmList = await _readModuleCriterionFromRepository.Where(x => x.TrialId == inDto.TrialId).ToListAsync(); - + List result = await _readModuleRepository.Where(x => x.TrialId == inDto.TrialId) + .Select(x => new GetCRCConfirmListOutDto() + { + SubjectId= x.SubjectId, + IsCRCConfirm = x.IsCRCConfirm, + LatestScanDate = x.SubjectVisit.LatestScanDate, + ReadingSetType = x.ReadingSetType, + IsPMConfirm = x.IsPMConfirm, + ReadModuleId = x.Id, + }).OrderBy(x => x.LatestScanDate).ToListAsync(); + var formList = await _clinicalFormRepository.Where(x => x.TrialId == inDto.TrialId) + .Where(x => x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC) + .Where(x => x.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.ImageRead || x.ClinicalDataTrialSet.ClinicalDataLevel == ClinicalLevel.OncologyRead) + .Select(x => new CRCClinicalForm + { + CkeckDate = x.CheckDate, + ClinicalDataLevel = x.ClinicalDataTrialSet.ClinicalDataLevel, + ClinicalFormId = x.Id, + }).ToListAsync(); + var confirmList = await _readModuleCriterionFromRepository.Where(x => x.TrialId == inDto.TrialId).ToListAsync(); result.ForEach(x => { if (x.IsCRCConfirm) { - x.FormCount = confirmList.Where(y => y.ReadModuleId == x.ReadModuleId).Count(); - + x.ClinicalFormIdList = confirmList.Where(y => y.ReadModuleId == x.ReadModuleId).Select(y=>y.ClinicalFormId).ToList(); } else { if (x.ReadingSetType == ReadingSetType.ImageReading) { - x.FormCount = formList.Where(y => y.ClinicalDataLevel == ClinicalLevel.ImageRead&&y.CkeckDate<=x.LatestScanDate).Count(); - + x.ClinicalFormIdList = formList.Where(y => y.ClinicalDataLevel == ClinicalLevel.ImageRead&&y.CkeckDate<=x.LatestScanDate).Select(y => y.ClinicalFormId).ToList(); } else { - x.FormCount = formList.Where(y => y.ClinicalDataLevel == ClinicalLevel.OncologyRead&&y.CkeckDate <= x.LatestScanDate).Count(); + x.ClinicalFormIdList = formList.Where(y => y.ClinicalDataLevel == ClinicalLevel.OncologyRead&&y.CkeckDate <= x.LatestScanDate).Select(y => y.ClinicalFormId).ToList(); } - } - }); return result; } + /// + /// CRC 确认临床数据 + /// + /// + /// + [HttpPost] + public async Task CRCConfirmClinical(CRCConfirmClinicalInDto inDto) + { + var dataList =await this.GetCRCConfirmList(new GetCRCConfirmListInDto() + { + TrialId = inDto.TrialId + }); + + var presentData = dataList.Where(x => x.ReadModuleId == inDto.ReadModuleId).First(); + var confirmlist= dataList.Where(x =>(x.LatestScanDate < presentData.LatestScanDate && x.ReadingSetType == presentData.ReadingSetType) + || x.ReadModuleId == presentData.ReadModuleId).Where(x => !x.IsCRCConfirm).ToList(); + + List needAddList = new List() + { + + }; + confirmlist.ForEach(x => + { + x.ClinicalFormIdList.ForEach(y => + { + needAddList.Add(new ReadModuleCriterionFrom() + { + ClinicalFormId = y, + ReadModuleId = x.ReadModuleId, + SubjectId = x.SubjectId, + TrialId = inDto.TrialId, + }); + }); + }); + + var readModuleIds = confirmlist.Select(x => x.ReadModuleId).ToList(); + + await _readModuleRepository.UpdatePartialFromQueryAsync(x => readModuleIds.Contains(x.Id),x=>new ReadModule() { + IsCRCConfirm=true + }); + await _readModuleCriterionFromRepository.AddRangeAsync(needAddList); + + await _readModuleCriterionFromRepository.SaveChangesAsync(); + + return ResponseOutput.Ok(true); + } + } } diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs index 081775f70..526d6253c 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalAnswerDto.cs @@ -99,10 +99,20 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TrialId { get; set; } } - public class CRCConfirmFormList + public class CRCConfirmClinicalInDto + { + public Guid TrialId { get; set; } + + public Guid ReadModuleId { get; set; } + } + + + public class CRCClinicalForm { public DateTime? CkeckDate { get; set; } + public Guid ClinicalFormId { get; set; } + /// /// 临床级别 /// @@ -125,7 +135,16 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public DateTime? LatestScanDate { get; set; } - public int FormCount { get; set; } + + public List ClinicalFormIdList { get; set; } + + public int FormCount + { + get + { + return this.ClinicalFormIdList.Count(); + } + } } public class SubmitClinicalFormInDto diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalQuestionDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalQuestionDto.cs index af441a447..9474d06c5 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalQuestionDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ClinicalQuestionDto.cs @@ -1,6 +1,8 @@ using IRaCIS.Core.Domain.Share; +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -178,7 +180,37 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// 单位 /// public string Unit { get; set; } = string.Empty; - } + + /// + /// 自定义计算标记 + /// + public ClinicalCalculateMark? CustomCalculateMark { get; set; } + + /// + /// 自定义计算问题 + /// + public string CalculateQuestions { get; set; } = "[]"; + + [NotMapped] + public List CalculateQuestionList + { + get + { + + try + { + var result = JsonConvert.DeserializeObject>(this.CalculateQuestions); + return result == null ? new List() : result; + } + catch (Exception) + { + + return new List(); + } + + } + } + } /// /// 查询临床数据基类 @@ -218,16 +250,6 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// 项目临床数据Id /// public Guid TrialClinicalId { get; set; } - - /// - /// 自定义计算标记 - /// - public ClinicalCalculateMark? ClinicalCalculateMarkEnum { get; set; } - - /// - /// 自定义计算问题 - /// - public string CalculateQuestions { get; set; } = "[]"; } /// diff --git a/IRaCIS.Core.Domain/Reading/ClinicalQuestion/SystemClinicalQuestion.cs b/IRaCIS.Core.Domain/Reading/ClinicalQuestion/SystemClinicalQuestion.cs index dac8fb262..ee996922a 100644 --- a/IRaCIS.Core.Domain/Reading/ClinicalQuestion/SystemClinicalQuestion.cs +++ b/IRaCIS.Core.Domain/Reading/ClinicalQuestion/SystemClinicalQuestion.cs @@ -126,7 +126,37 @@ namespace IRaCIS.Core.Domain.Models /// 单位 /// public string Unit { get; set; } = string.Empty; - } + + /// + /// 自定义计算标记 + /// + public ClinicalCalculateMark? CustomCalculateMark { get; set; } + + /// + /// 自定义计算问题 + /// + public string CalculateQuestions { get; set; } = "[]"; + + [NotMapped] + public List CalculateQuestionList + { + get + { + + try + { + var result = JsonConvert.DeserializeObject>(this.CalculateQuestions); + return result == null ? new List() : result; + } + catch (Exception) + { + + return new List(); + } + + } + } + } } diff --git a/IRaCIS.Core.Domain/Reading/ClinicalQuestion/TrialClinicalQuestion.cs b/IRaCIS.Core.Domain/Reading/ClinicalQuestion/TrialClinicalQuestion.cs index 97ef17e9e..f741b2f93 100644 --- a/IRaCIS.Core.Domain/Reading/ClinicalQuestion/TrialClinicalQuestion.cs +++ b/IRaCIS.Core.Domain/Reading/ClinicalQuestion/TrialClinicalQuestion.cs @@ -8,6 +8,7 @@ using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using IRaCIS.Core.Domain.Models; +using System.Collections.Generic; namespace IRaCIS.Core.Domain.Models { @@ -125,17 +126,37 @@ namespace IRaCIS.Core.Domain.Models /// /// 自定义计算标记 /// - public ClinicalCalculateMark? ClinicalCalculateMarkEnum { get; set; } + public ClinicalCalculateMark? CustomCalculateMark { get; set; } /// /// 自定义计算问题 /// public string CalculateQuestions { get; set; } = "[]"; - /// - /// 小数点位数 - /// - public int? DigitPlaces { get; set; } + [NotMapped] + public List CalculateQuestionList + { + get + { + + try + { + var result = JsonConvert.DeserializeObject>(this.CalculateQuestions); + return result == null ? new List() : result; + } + catch (Exception) + { + + return new List(); + } + + } + } + + /// + /// 小数点位数 + /// + public int? DigitPlaces { get; set; } /// /// 单位