From 681c0fd02ef058ce4be97c69cc2792bcf8e65a12 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 17 Aug 2022 17:27:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=85=E7=89=87=E6=9C=9F=E7=A8=BD=E6=9F=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 16 +- .../Service/Reading/ReadModuleService.cs | 116 +--------- .../Reading/ReadingPeriodSetService.cs | 7 +- .../Service/WorkLoad/EnrollService.cs | 5 +- IRaCIS.Core.Domain/SQLFile/Sql脚本.sql | 3 + .../Common/AuditingData.cs | 210 ++++++++++++------ .../Common/Dto/SetDictionaryValueDto.cs | 4 - 7 files changed, 168 insertions(+), 193 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index b2cab7c57..c04707038 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -3110,6 +3110,13 @@ + + + 设置项目器官是否生效 + + + + 阅片医学审核 @@ -6931,13 +6938,6 @@ 生成的阅片模块(在大列表上展示的) 阅片期 - - - 获取读片计划列表 byZhouhang - - - - 获取读片模块 @@ -7215,7 +7215,7 @@ - optType 0表示回退,回退之后,列表没这条数据了, 1表示出组,需要填写出组时间 + optType 0表示入组,列表没这条数据了, 1表示出组,需要填写出组时间 废弃 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index 1e3c4f453..a0fd3071c 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -1,15 +1,7 @@ -using IRaCIS.Application.Interfaces; -using IRaCIS.Core.Infra.EFCore; -using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Domain.Share; using Microsoft.AspNetCore.Mvc; -using IRaCIS.Core.Application.Service.WorkLoad.DTO; -using Microsoft.AspNetCore.Authorization; -using IRaCIS.Core.Application.Auth; using IRaCIS.Core.Application.Service.Reading.Dto; using MassTransit; -using Panda.DynamicWebApi.Attributes; -using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Infra.EFCore.Common; using System.Linq.Dynamic.Core; using IRaCIS.Core.Application.Service; @@ -71,89 +63,6 @@ namespace IRaCIS.Application.Services } - /// - /// 获取读片计划列表 byZhouhang - /// - /// - /// - public async Task<(PageOutput, object)> GetReadPlanList(GetReadModuleDto dto) - { - var subjectQuery = _subjectRepository - .WhereIf(dto.TrialId != null, x => x.TrialId == dto.TrialId) - .WhereIf(dto.SubjectId != null, x => x.Id == dto.SubjectId) - .WhereIf(dto.TrialSiteCode != null, x => x.TrialSite.TrialSiteCode == dto.TrialSiteCode) - .WhereIf(dto.SubjectCode != null, x => x.Code == dto.SubjectCode) - - - - .Select(x => new ReadPlanView - { - TrialSiteCode = x.TrialSite.TrialSiteCode, - SiteCode = x.TrialSite.TrialSiteCode, - SiteId = x.SiteId, - SubjectCode = x.Code, - SubjectId = x.Id, - - //Data = x.SubjectVisitList.OrderByDescending(y => y.VisitNum).Select(y => new GetReadModuleOutDto() - //{ - // Id = y.Id, //id - // Name = y.VisitName, - // ModuleType = y.InPlan ? ModuleTypeEnum.InPlanSubjectVisit : ModuleTypeEnum.OutPlanSubjectVisit, // 模块类型 - // IsUrgent = x.IsUrgent, // 是否加急 - // SubjectVisitId = y.Id, // 访视ID - // SubjectVisitName = y.VisitName, // 访视名称 - // Status = ReadingCommon.GetVisitSubmitStateEnum(y), // 状态 - // CreateTime = y.CreateTime, // 创建时间 - // SubjectCode = y.Subject.Code, // 受试者code - // TrialSiteCode = x.TrialSite.TrialSiteCode, // 中心Code - // VisitNum = y.VisitNum, - - // IsFinalVisit = y.IsFinalVisit, // 是否为末次评估 - // OutPlanPreviousVisitId = y.OutPlanPreviousVisitId, // 上一访视 - // OutPlanPreviousVisitName = y.OutPlanPreviousVisit.VisitName, // 上一访视名称 - // SiteId = x.Site.Id, // 中心ID - // IsVisit = true, // 是否为访视 - // PDState = y.PDState, // PD 进展 - // IsEnrollmentConfirm = y.IsEnrollmentConfirm, // 入组 - // SubjectId = x.Id, - //}).ToList(), - - //ReadModuleData = x.ReadModuleList.Select( - // z => new GetReadModuleOutDto() - // { - // CreateTime = z.CreateTime, - // Id = z.Id, - // Name = z.ModuleName, - // SubjectId = x.Id, - // ModuleType = z.ModuleType, - // Status = ReadingCommon.GetVisitSubmitStateEnum(z.SubjectVisit), - // SubjectCode = x.Code, - // TrialSiteCode = x.TrialSite.TrialSiteCode, - // SubjectVisitId = z.SubjectVisitId, - // SubjectVisitName = z.SubjectVisit.VisitName, // 截止访视名称 - // CutOffVisitId = z.SubjectVisitId, // 截止访视 - // CutOffVisitName = z.SubjectVisit.VisitName, // 截止访视名称 - // ReadModuleId = z.ReadModuleId, - // ReadModuleName = z.ReadModuleModel.ModuleName, - // IsUrgent = z.IsUrgent - // }).ToList(), - - }); - - var pageList = await subjectQuery.ToPagedListAsync(dto.PageIndex, dto.PageSize, dto.SortField == null || dto.SortField == string.Empty ? "SiteCode" : dto.SortField, - dto.Asc); - - return (pageList, new - { - MaxLength = pageList.CurrentPageData.ToList().Count() - }); - } - - - - - - /// /// 获取读片模块 /// @@ -215,17 +124,6 @@ namespace IRaCIS.Application.Services - - ///// - ///// 访视阅片完成添加阅片期模块 - ///// - ///// - //public async Task VisitFinishReadingAddReadModule(VisitFinishReadingAddReadModuleInDto inDto) - //{ - // var subjectVisit = await _subjectRepository.FirstOrDefaultNoTrackingAsync(x => x.Id == inDto.SubjectVisitId); - // List readingPeriodSets= _readingPeriodSetRepository.Where(x=>x.TrialId==inDto.TrialId&&x.IsTakeEffect=&&(x.ReadingScope==ReadingScopeEnum.All||(x.ReadingScope==ReadingScopeEnum.Site&&x.ReadingPeriodSites.Select(y=>y.SiteId).Contains(subjectVisit.SiteId)))) - //} - /// /// 获取单条详情信息 /// @@ -445,18 +343,6 @@ namespace IRaCIS.Application.Services } - ///// - ///// 新增或者修改 - ///// - ///// - ///// - //[HttpPost] - //public async Task AddOrUpdateReadModuleService(ReadModuleAddOrEdit addOrEditReadModule) - //{ - // var entity = await _repository.InsertOrUpdateAsync(addOrEditReadModule, true); - // return ResponseOutput.Ok(entity.Id.ToString()); - //} - /// diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs index 408327e74..726930b10 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriodSetService.cs @@ -446,6 +446,7 @@ namespace IRaCIS.Application.Services { TaskState = TaskState.Adbandon }); + await _readModuleRepository.DeleteFromQueryAsync(x => x.ReadingPeriodSetId == indto.Id); } @@ -469,8 +470,10 @@ namespace IRaCIS.Application.Services [HttpDelete("{readingPeriodSetId:guid}")] public async Task DeleteReadingPeriodSet(Guid readingPeriodSetId) { - var success = await _repository.BatchDeleteAsync(t => t.Id == readingPeriodSetId); - return ResponseOutput.Result(success); + await _readingPeriodSetRepository.DeleteFromQueryAsync(t => t.Id == readingPeriodSetId,true); + await _readingPeriodPlanRepository.DeleteFromQueryAsync(t => t.ReadingPeriodSetId == readingPeriodSetId, true); + + return ResponseOutput.Ok(); } } } diff --git a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs index f8ca5591d..bb2793a3d 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs @@ -433,8 +433,10 @@ namespace IRaCIS.Application.Services } + + /// - /// optType 0表示回退,回退之后,列表没这条数据了, 1表示出组,需要填写出组时间 + /// optType 0表示入组,列表没这条数据了, 1表示出组,需要填写出组时间 废弃 /// /// /// @@ -444,6 +446,7 @@ namespace IRaCIS.Application.Services [HttpPost("{trialId:guid}/{doctorId:guid}/{optType:int}")] [TypeFilter(typeof(TrialResourceFilter))] [Authorize(Policy = IRaCISPolicy.PM_APM_SPM_CPM)] + [Obsolete] public async Task EnrollBackOrOut(Guid trialId, Guid doctorId, int optType, DateTime? outEnrollTime) { var intoGroupItem = await _enrollRepository.FirstOrDefaultAsync(t => t.TrialId == trialId && t.DoctorId == doctorId); diff --git a/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql b/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql index 7c2b8bce6..b56462a97 100644 --- a/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql +++ b/IRaCIS.Core.Domain/SQLFile/Sql脚本.sql @@ -20,3 +20,6 @@ update Doctor set Physician='Deputy Chief Physician',PhysicianCN=' update Doctor set RankOther='Professor',RankOtherCN='' where RankId='dcbf4d1a-8373-4539-a0ae-1ba76d57bb48' update Doctor set RankOther='Associate Professor',RankOtherCN='' where RankId='3a6e3335-cea4-4803-a136-d6301883a937' update Doctor set Physician='Staff',PhysicianCN='ҽʦ' where RankId='82411c2e-9832-4c6f-a859-e3b6e796760d' + + +update DataInspection set JsonDetail= replace(cast(JsonDetail as varchar(max)),'Insepection','CommonData') diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index d50cd7644..1b2db412c 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -847,14 +847,74 @@ namespace IRaCIS.Core.Infra.EFCore.Common } - //// 医生详情 - //foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(EnrollDetail))) - //{ - // await InsertInspection(item.Entity as EnrollDetail, type, x => new DataInspection() - // { - // GeneralId = x.Id, - // }); - //} + //阅片期 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodSet))) + { + var entity = item.Entity as ReadingPeriodSet; + + var visitName = _dbContext.VisitPlans.Where(t => t.Id == entity.VisitStageId).Select(t => t.VisitName).FirstOrDefault(); + + var siteCodes = string.Empty; + if (entity.ReadingScope == ReadingScopeEnum.Site) + { + var siteIds = entity.ReadingPeriodSites.Select(t => t.SiteId).ToList(); + var nameList = _dbContext.TrialSite.Where(c => c.TrialId == entity.TrialId && siteIds.Contains(c.SiteId) ).Select(t => t.TrialSiteCode).ToList(); + + siteCodes = String.Join(',', nameList); + } + + + await InsertInspection(item.Entity as ReadingPeriodSet, type, x => new InspectionConvertDTO() + { + GeneralId = x.Id, + }, new + { + VisitName = visitName, + SiteCodes = siteCodes + }); + } + + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadingPeriodPlan))) + { + var entity = item.Entity as ReadingPeriodPlan; + + if (entity.ReadingPeriodSet == null) + { + entity.ReadingPeriodSet = _dbContext.ReadingPeriodSet.Find(entity.ReadingPeriodSetId); + } + + await InsertInspection(item.Entity as ReadingPeriodPlan, type, x => new InspectionConvertDTO() + { + GeneralId = x.Id, + SubjectVisitId = x.SubjectVisitId, + }, new + { + entity.ReadingPeriodSet.ReadingPeriodName, + entity.ReadingPeriodSet.EffectOfTime, + entity.ReadingPeriodSet.ExpirationDate + }); + } + + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ReadModule))) + { + var entity = item.Entity as ReadModule; + + //if (entity.ReadingPeriodSet == null && entity.ReadingPeriodSetId !=null) + //{ + // entity.ReadingPeriodSet = _dbContext.ReadingPeriodSet.Find(entity.ReadingPeriodSetId); + //} + + var visitName = _dbContext.SubjectVisit.Where(t => t.Id == entity.SubjectVisitId).Select(t => t.VisitName).FirstOrDefault(); + await InsertInspection(item.Entity as ReadModule, type, x => new InspectionConvertDTO() + { + GeneralId = x.Id, + SubjectVisitId = x.SubjectVisitId, + }, new + { + + VisitName = visitName, + }); + } #endregion @@ -887,8 +947,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common //将实体对象属性 映射到稽查实体 MapEntityPropertyToAuditEntity(entityObj, inspection); - var generalData = await GetInspectionGeneralDataAsync(inspection); + var generalData = await GetInspectionGeneralDataAsync( inspection); + //不可少 因为稽查实体可能某些Id没有 + MapEntityPropertyToAuditEntity(generalData, inspection); #region 处理标识 @@ -965,14 +1027,14 @@ namespace IRaCIS.Core.Infra.EFCore.Common /// /// /// - public async Task GetInspectionGeneralDataAsync(InspectionConvertDTO inspection) + public async Task GetInspectionGeneralDataAsync( InspectionConvertDTO inspection) { InspectionGeneralData generalData = new InspectionGeneralData() { SiteCode = inspection.SiteCode, SiteId = inspection.SiteId, - SiteName = inspection.SiteName, + //SiteName = inspection.SiteName, SubjectCode = inspection.SubjectCode, SubjectId = inspection.SubjectId, SubjectVisitId = inspection.SubjectVisitId, @@ -983,6 +1045,74 @@ namespace IRaCIS.Core.Infra.EFCore.Common }; + + + #region 访视 阅片期那里关联了访视 + + if (generalData.SubjectVisitId != null) + { + //添加访视的时候,会带信息过来 + if (string.IsNullOrEmpty(generalData.SubjectVisitName)) + { + var info = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => + new { x.VisitName, x.SubjectId, x.SiteId, SubjectCode = x.Subject.Code, TrialSiteCode = x.TrialSite.TrialSiteCode ,x.TrialId,x.Trial.ExperimentName,x.Trial.ResearchProgramNo}).FirstOrDefaultAsync()).IfNullThrowException(); + + generalData.SubjectVisitName = info.VisitName; + + generalData.TrialId = info.TrialId; + generalData.TrialName = info.ExperimentName; + generalData.ResearchProgramNo = info.ResearchProgramNo; + generalData.SiteId = info.SiteId; + generalData.SubjectCode = info.SubjectCode; + generalData.SubjectId = info.SubjectId; + generalData.SiteCode = info.TrialSiteCode; + } + } + + + #endregion + + + #region 受试者 + + if (generalData.SubjectId != null) + { + + // 添加Subject 哪里会带信息过来 + if (string.IsNullOrEmpty(generalData.SubjectCode)) + { + var info = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => new { SubjectId = x.Id, SubjectCode = x.Code, x.SiteId, TrialSiteCode = x.TrialSite.TrialSiteCode, x.TrialId, x.Trial.ExperimentName, x.Trial.ResearchProgramNo }).FirstOrDefaultAsync()).IfNullThrowException(); + + + generalData.TrialId = info.TrialId; + generalData.TrialName = info.ExperimentName; + generalData.ResearchProgramNo = info.ResearchProgramNo; + generalData.SiteId = info.SiteId; + generalData.SubjectCode = info.SubjectCode; + generalData.SubjectId = info.SubjectId; + generalData.SiteCode = info.TrialSiteCode; + + } + } + + #endregion + + + + #region 中心Code + + if (generalData.TrialId != null && generalData.SiteId != null) + { + + generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException(); + + + } + + + #endregion + + #region 项目名称 @@ -1002,53 +1132,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common #endregion - #region 测试中心名称 - if (generalData.TrialId != null && generalData.SiteId != null) - { - - generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException(); - - - // 添加Site 哪里会带信息过来 - if (string.IsNullOrEmpty(generalData.SiteName)) - { - generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException(); - - } - } - - - #endregion - - #region 受试者 - - if (generalData.SubjectId != null) - { - - // 添加Subject 哪里会带信息过来 - if (string.IsNullOrEmpty(generalData.SubjectCode)) - { - generalData.SubjectCode = (await _dbContext.Subject.Where(x => x.Id == generalData.SubjectId).Select(x => x.Code).FirstOrDefaultAsync()).IfNullThrowException(); - - } - } - - #endregion - - #region 访视 - - if (generalData.SubjectVisitId != null) - { - //添加访视的时候,会带信息过来 - if (string.IsNullOrEmpty(generalData.SubjectVisitName)) - { - generalData.SubjectVisitName = (await _dbContext.SubjectVisit.Where(x => x.Id == generalData.SubjectVisitId).Select(x => x.VisitName).FirstOrDefaultAsync()).IfNullThrowException(); - } - } - - - #endregion return generalData; } @@ -1218,7 +1302,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common //CreateUserName = add.CreateUserName, SiteCode = add.SiteCode, SiteId = add.SiteId, - SiteName = add.SiteName, + //SiteName = add.SiteName, SubjectCode = add.SubjectCode, SubjectId = add.SubjectId, SubjectVisitId = add.SubjectVisitId, @@ -1302,12 +1386,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common generalData.SiteCode = (await _dbContext.TrialSite.IgnoreQueryFilters().Where(x => x.TrialId == generalData.TrialId && x.SiteId == generalData.SiteId).Select(t => t.TrialSiteCode).FirstOrDefaultAsync()).IfNullThrowException(); - // 添加Site 哪里会带信息过来 - if (string.IsNullOrEmpty(generalData.SiteName)) - { - generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException(); + //// 添加Site 哪里会带信息过来 + //if (string.IsNullOrEmpty(generalData.SiteName)) + //{ + // generalData.SiteName = (await _dbContext.Site.Where(x => x.Id == generalData.SiteId).Select(x => x.SiteName).FirstOrDefaultAsync()).IfNullThrowException(); - } + //} } diff --git a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs index b07218388..254bba41a 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/Dto/SetDictionaryValueDto.cs @@ -175,10 +175,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common.Dto /// public string ResearchProgramNo { get; set; } - /// - /// 中心名称 - /// - public string SiteName { get; set; } /// /// 受试者名称