diff --git a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs index 1d57b2e30..ea973ec9a 100644 --- a/IRaCIS.Core.API/Controllers/FinancialChangeController.cs +++ b/IRaCIS.Core.API/Controllers/FinancialChangeController.cs @@ -11,6 +11,7 @@ using IRaCIS.Application.Services; using IRaCIS.Core.Application.Service.Inspection.DTO; using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Application.Service.Inspection.Interface; +using IRaCIS.Core.Domain.Models; namespace IRaCIS.Core.API.Controllers.Special { @@ -43,7 +44,10 @@ namespace IRaCIS.Core.API.Controllers.Special public async Task AddOrUpdateTrialInspection(DataInspectionDto opt) { - var fun = AddOrUpdateTrial; + var fun =await AddOrUpdateTrial(opt.OptCommand); + opt.AuditInfo.TrialId = fun.Data.Id; + opt.AuditInfo.TrialName = fun.Data.ExperimentName; + opt.AuditInfo.ResearchProgramNo = fun.Data.ResearchProgramNo; return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun); } @@ -53,7 +57,7 @@ namespace IRaCIS.Core.API.Controllers.Special /// 新记录Id [HttpPost, Route("trial/addOrUpdateTrial")] - public async Task AddOrUpdateTrial(TrialCommand param) + public async Task> AddOrUpdateTrial(TrialCommand param) { var userId = Guid.Parse(User.FindFirst("id").Value); var result = await _trialService.AddOrUpdateTrial(param); diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index 244542980..174c4b5c2 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -53,7 +53,7 @@ namespace IRaCIS.Core.API.Controllers ITrialDocumentService trialDocumentService, IRepository dataInspectionRepository, IQCListService _qCListService, - IHttpContextAccessor httpContext, + IHttpContextAccessor httpContext, IInspectionService sinspectionService, ITrialConfigService _trialConfigService, INoneDicomStudyService noneDicomStudyService, diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index 7605a7f0f..e25097410 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -114,6 +114,9 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO public bool NeedSava { get; set; } = true; + + + } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs index 4b7483c75..96328c88c 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/Interface/ITrialService.cs @@ -7,7 +7,7 @@ namespace IRaCIS.Application.Interfaces { bool TrialExpeditedChange { get; set; } - Task AddOrUpdateTrial(TrialCommand trialAddModel); + Task> AddOrUpdateTrial(TrialCommand trialAddModel); Task ConfirmTrialVisitPlan(Guid trialId, bool confirmOrCancel = true); Task DeleteTrial(Guid trialId); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 5ea307176..c24686a44 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -7,6 +7,7 @@ using IRaCIS.Core.Infra.EFCore; using MassTransit; using Microsoft.AspNetCore.Mvc; using Panda.DynamicWebApi.Attributes; +using IRaCIS.Core.Infrastructure; namespace IRaCIS.Application.Services { @@ -128,21 +129,22 @@ namespace IRaCIS.Application.Services /// /// [NonDynamicMethod] - public virtual async Task AddOrUpdateTrial(TrialCommand trialAddModel) + public virtual async Task> AddOrUpdateTrial(TrialCommand trialAddModel) { // 到时候 策略授权 统一改 归类 if (!(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin)) { - return ResponseOutput.NotOk("仅PM/APM可以操作!"); + throw new BusinessValidationFailedException("仅PM/APM可以操作!"); + } if (trialAddModel.Id == Guid.Empty || trialAddModel.Id == null) { if (await _trialRepository.AnyAsync(u => u.TrialCode == trialAddModel.TrialCode)) { - return ResponseOutput.NotOk("Same Trial ID already exists."); + throw new BusinessValidationFailedException("Same Trial ID already exists."); } var dbMaxCode = await _trialRepository.Where(t => t.CreateTime.Year == DateTime.Now.Year && t.TrialType == trialAddModel.TrialType).Select(t => t.Code).DefaultIfEmpty().MaxAsync(); @@ -171,7 +173,7 @@ namespace IRaCIS.Application.Services //状态变更详细表 trial.ClinicalTrialProjectDetails.Add(new TrialStatusDetail() { TrialId = trial.Id, TrialStatus = (int)TrialEnrollStatus.ChooseDoctor }); - trial = await _repository.AddAsync(trial); + trial = await _trialRepository.AddAsync(trial); //如果是PM, 则需要将该人员添加到 运维人员表 //添加运维人员PM @@ -189,7 +191,7 @@ namespace IRaCIS.Application.Services _provider.Set(trial.Id.ToString(), StaticData.TrialInitializing, TimeSpan.FromDays(7)); - return ResponseOutput.Result(success, new { Id = trial.Id, TrialCode = trial.TrialCode }); + return ResponseOutput.Ok(trial); } else { @@ -197,13 +199,13 @@ namespace IRaCIS.Application.Services if (!await _repository.AnyAsync(u => u.Id == trialAddModel.Id && (u.TrialStatusStr == StaticData.TrialInitializing || u.TrialStatusStr == StaticData.TrialOngoing))) { - return ResponseOutput.NotOk("项目初始化或者进行中时 才允许操作"); + throw new BusinessValidationFailedException("项目初始化或者进行中时 才允许操作"); + } // 判断项目Id 是否已经存在 if (await _repository.AnyAsync(u => u.TrialCode == updateModel.TrialCode && u.Id != updateModel.Id)) { - return ResponseOutput.NotOk("Same Trial ID already exists."); - + throw new BusinessValidationFailedException("Same Trial ID already exists."); } @@ -229,8 +231,8 @@ namespace IRaCIS.Application.Services _mapper.Map(updateModel, trial); var success = await _repository.SaveChangesAsync(); - - return ResponseOutput.Result(success); + return ResponseOutput.Ok(trial); + } diff --git a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs index d0c217ef7..a8107e7e3 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/Repository.cs @@ -675,7 +675,24 @@ namespace IRaCIS.Core.Infra.EFCore { List datas = new List(); - var createtime = DateTime.Now.AddSeconds(1); + var createtime = DateTime.Now.AddMilliseconds(200); + + // 项目 + if (typeof(TEntity) == typeof(Trial)) + { + Trial data = entity as Trial; + datas.Add(new DataInspection() + { + TrialId = data.Id, + SubjectId = data.Id, + TrialName=data.ExperimentName, + ResearchProgramNo=data.ResearchProgramNo, + IsSign = false, + CreateTime = createtime, + Identification = "Init|Trial|Status|Trial Setting-Infomation", // 初始化项目 + JsonDetail = entity.ToJcJson() + }); + } // 受试者 if (typeof(TEntity) == typeof(Subject)) @@ -687,6 +704,7 @@ namespace IRaCIS.Core.Infra.EFCore SiteId = data.SiteId, SubjectId = data.Id, SubjectCode = data.Code, + IsSign = false, CreateTime = createtime, Identification = "Init|Subject|Status|Subject", // 初始化受试者信息 @@ -874,7 +892,12 @@ namespace IRaCIS.Core.Infra.EFCore #region 项目名称 var trialdata = await _dbContext.Trial.Select(x => new { x.Id, x.ResearchProgramNo, x.ExperimentName, }).FirstOrDefaultAsync(x => x.Id == Data.TrialId); - Data.ResearchProgramNo = trialdata?.ResearchProgramNo; + if (IsNullOrEmpty(Data.ResearchProgramNo)) + { + + Data.ResearchProgramNo = trialdata?.ResearchProgramNo; + } + if (IsNullOrEmpty(Data.TrialName)) { Data.TrialName = trialdata?.ExperimentName;