diff --git a/IRaCIS.Core.API/Controllers/InspectionController.cs b/IRaCIS.Core.API/Controllers/InspectionController.cs index e29e4b9c6..78e0bc10e 100644 --- a/IRaCIS.Core.API/Controllers/InspectionController.cs +++ b/IRaCIS.Core.API/Controllers/InspectionController.cs @@ -137,9 +137,22 @@ namespace IRaCIS.Core.API.Controllers public async Task AddOrUpdateSubject(InsSubjectCommand opt) { - opt.AuditInfo.SubjectId = opt.OptCommand.Id; - var fun = _subjectService.AddOrUpdateSubject; - return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, fun); + + var fun = await _subjectService.AddOrUpdateSubject(opt.OptCommand); + opt.AuditInfo.SubjectId = Guid.Parse(fun.Data); + + var statusdata = new { + Status = 1, + OutEnrollmentTime = DateTime.Now.ToString("yyyy-MM-dd"), + VisitOverTime = DateTime.Now.ToString("yyyy-MM-dd"), + Reason = string.Empty, + }; + + + + + + return await _inspectionService.Enforcement(opt.OptCommand, opt.AuditInfo, opt.SignInfo, null, fun, statusdata); } /// diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 65eab2306..1736c74e8 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -670,7 +670,7 @@ 是否有签名 - + 通用逻辑封装 @@ -678,6 +678,8 @@ 添加稽查 用户签名 委托 + 方法返回的结果 + 添加状态的对象 @@ -693,8 +695,14 @@ 添加签名记录 /// - - 添加稽查记录( 有的会签名,有的不会签名) /// + + + 添加稽查记录 + + 添加对象 + 签名Id + 初始化状态对象 + diff --git a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs index 703f91773..ce07b8013 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/FrontAuditConfigViewModel.cs @@ -12,33 +12,37 @@ namespace IRaCIS.Core.Application.ViewModel public class FrontAuditConfigView { public Guid Id { get; set; } - public string Value { get; set; } - public string ValueCN { get; set; } - public string Description { get; set; } - public DateTime CreateTime { get; set; } + public string Value { get; set; } = string.Empty; + public string ValueCN { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public DateTime CreateTime { get; set; } public Guid CreateUserId { get; set; } public DateTime UpdateTime { get; set; } public Guid UpdateUserId { get; set; } - public string Code { get; set; } - public Guid? ParentId { get; set; } + public string Code { get; set; } = string.Empty; + public Guid? ParentId { get; set; } public bool? IsEnable { get; set; } public bool? IsConfig { get; set; } - public string ModuleTypeId { get; set; } - public string OptTypeId { get; set; } - public string ChildrenTypeId { get; set; } + public string ModuleTypeId { get; set; } = string.Empty; + public string OptTypeId { get; set; } = string.Empty; + public string ChildrenTypeId { get; set; } = string.Empty; - public string ConfigType { get; set; } + public string ConfigType { get; set; } = string.Empty; - public bool? IsShowParent { get; set; } + public bool? IsShowParent { get; set; } - public string ChildrenTypeValue { get; set; } - public string ChildrenTypeValueCN { get; set; } - - public string ModuleTypeValue { get; set; } - public string ModuleTypeValueCN { get; set; } - - public string OptTypeValue { get; set; } - public string OptTypeValueCN { get; set; } + public string ChildrenTypeValue { get; set; } = string.Empty; + public string ChildrenTypeValueCN { get; set; } = string.Empty; + + public string ModuleTypeValue { get; set; } = string.Empty; + public string ModuleTypeValueCN { get; set; } = string.Empty; + + public string OptTypeValue { get; set; } = string.Empty; + public string OptTypeValueCN { get; set; } = string.Empty; + + public int? Sort { get; set; } + + } ///FrontAuditConfigQuery 列表查询参数模型 @@ -87,6 +91,8 @@ namespace IRaCIS.Core.Application.ViewModel public bool? IsShowParent { get; set; } + public int? Sort { get; set; } + } diff --git a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs index 777766c3c..ebc523445 100644 --- a/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Common/FrontAuditConfigService.cs @@ -67,7 +67,7 @@ namespace IRaCIS.Core.Application.Service OptTypeValue = leftOptTypeId.Value, OptTypeValueCN = leftOptTypeId.ValueCN, UpdateUserId = data.UpdateUserId, - + Sort=data.Sort, ValueCN = data.ValueCN, ChildrenTypeValue = leftchildrenType.Value, }; @@ -80,7 +80,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(!iq.Value.IsNullOrEmpty(), x => x.Code == iq.Code) .WhereIf(!iq.Value.IsNullOrEmpty(), x => x.ChildrenTypeId == iq.ChildrenTypeId); - return await query.ToListAsync(); + return await query.OrderBy(x=>x.Sort).ToListAsync(); } diff --git a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs index 030bdff85..3cfb86dfa 100644 --- a/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs +++ b/IRaCIS.Core.Application/Service/Inspection/DTO/InspectionModel.cs @@ -31,7 +31,7 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO /// /// 子类 /// - public string ChildrenType { get; set; } + public string ChildrenType { get; set; } = string.Empty; public bool IsSign { get; set; } public string JsonDetail { get; set; } = string.Empty; @@ -141,6 +141,8 @@ namespace IRaCIS.Core.Application.Service.Inspection.DTO public string UserFirstName { get; set; } = string.Empty; public string UserLastName { get; set; } = string.Empty; + public string SubjectCode { get; set; } = string.Empty; + } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index ca3965524..0997f6de9 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -3,6 +3,7 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Service.Inspection.DTO; using IRaCIS.Core.Application.Service.Inspection.Interface; using IRaCIS.Core.Domain.Share; +using Newtonsoft.Json; using Panda.DynamicWebApi.Attributes; using System; using System.Collections.Generic; @@ -66,6 +67,7 @@ namespace IRaCIS.Core.Application.Service.Inspection CreateUser = leftuser.UserName, UserFirstName = leftuser.FirstName, UserLastName = leftuser.LastName, + SubjectCode=leftsubject.Code, }; query = query.WhereIf(!dto.BlindName.IsNullOrEmpty(), x => x.BlindName == dto.BlindName) @@ -126,8 +128,10 @@ namespace IRaCIS.Core.Application.Service.Inspection /// 添加稽查 /// 用户签名 /// 委托 + /// 方法返回的结果 + /// 添加状态的对象 /// - public async Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput response=null) + public async Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response=null, object? Statusdata=null) { Guid? signId = null; MapData(OptCommand, AuditInfo); @@ -164,7 +168,7 @@ namespace IRaCIS.Core.Application.Service.Inspection // 判断是否需要前面 - await AddInspectionRecordAsync(AuditInfo, signId); + await AddInspectionRecordAsync(AuditInfo, signId, Statusdata); if (bResult.IsSuccess == false) { @@ -224,18 +228,49 @@ namespace IRaCIS.Core.Application.Service.Inspection } - /// 添加稽查记录( 有的会签名,有的不会签名) /// - public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId) + /// + /// 添加稽查记录 + /// + /// 添加对象 + /// 签名Id + /// 初始化状态对象 + /// + public async Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId, object? Statusdata = null) { var add = _mapper.Map(addDto); Guid? parentId = null; - parentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == x.SiteId).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; + parentId = (await _repository.GetQueryable().Where(x => x.TrialId == add.TrialId && x.SubjectVisitId == add.SubjectVisitId && x.SubjectId == add.SubjectId && x.SiteId == add.SiteId&&x.ModuleType==add.ModuleType&&x.ChildrenType==add.ChildrenType).OrderByDescending(x => x.CreateTime).FirstOrDefaultAsync())?.Id; add.ParentId = parentId; add.CreateTime = DateTime.Now; add.CreateUserId = _userInfo.Id; add.SignId = signId; add.IP = _userInfo.IP; await _repository.AddAsync(add); + if (addDto.OptType.ToLower() == "Add".ToLower()|| Statusdata!=null) + { + + + DataInspection ststus = new DataInspection() + { + SignId = signId, + SiteId = add.SiteId, + SubjectId = add.SubjectId, + SubjectVisitId = add.SubjectVisitId, + IsSign = add.IsSign, + BlindName = add.BlindName, + ChildrenType = "Status", + OptType = "Init", + CreateTime = add.CreateTime, + CreateUserId = add.CreateUserId, + IP = add.IP, + ModuleType = add.ModuleType, + TrialId = add.TrialId, + JsonDetail = JsonConvert.SerializeObject(Statusdata) + }; + + await _repository.AddAsync(ststus); + } + var success = await _repository.SaveChangesAsync(); return ResponseOutput.Ok(success); diff --git a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs index 8c3368bc9..f939563b6 100644 --- a/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/Interface/IInspectionService.cs @@ -19,8 +19,8 @@ namespace IRaCIS.Core.Application.Service.Inspection.Interface Task AddSignRecordAsync(SignDTO signDTO); - Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput response = null); + Task Enforcement(dynamic OptCommand, DataInspectionAddDTO AuditInfo, SignDTO SignInfo, dynamic fun, IResponseOutput? response = null, object? Statusdata = null); - Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId); + Task AddInspectionRecordAsync(DataInspectionAddDTO addDto, Guid? signId, object? Statusdata = null); } } diff --git a/IRaCIS.Core.Application/Service/Visit/DTO/ClinicalStudySubjects.cs b/IRaCIS.Core.Application/Service/Visit/DTO/ClinicalStudySubjects.cs index b589c3949..44f84ad60 100644 --- a/IRaCIS.Core.Application/Service/Visit/DTO/ClinicalStudySubjects.cs +++ b/IRaCIS.Core.Application/Service/Visit/DTO/ClinicalStudySubjects.cs @@ -43,9 +43,14 @@ namespace IRaCIS.Application.Contracts public class SubjectStatusChangeCommand { - [NotDefault] + public Guid SubjectId { get; set; } + + public Guid? TrialId { get; set; } + + public Guid? SiteId { get; set; } + public SubjectStatus Status { get; set; } public DateTime? OutEnrollmentTime { get; set; } public DateTime? VisitOverTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/Visit/Interface/ISubjectService.cs b/IRaCIS.Core.Application/Service/Visit/Interface/ISubjectService.cs index 798d1e78b..0db901be6 100644 --- a/IRaCIS.Core.Application/Service/Visit/Interface/ISubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/Interface/ISubjectService.cs @@ -5,7 +5,7 @@ namespace IRaCIS.Application.Interfaces { public interface ISubjectService { - Task AddOrUpdateSubject([FromBody] SubjectCommand subjectCommand); + Task> AddOrUpdateSubject([FromBody] SubjectCommand subjectCommand); Task DeleteSubject(Guid id); Task UpdateSubjectStatus(SubjectStatusChangeCommand subjectStatusChangeCommand); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index 9604fba59..013a3ce32 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -25,7 +25,7 @@ namespace IRaCIS.Application.Services [TrialAudit(AuditType.SubjectAudit, AuditOptType.AddOrUpdateSubject)] [TypeFilter(typeof(TrialResourceFilter))] - public async Task AddOrUpdateSubject([FromBody] SubjectCommand subjectCommand) + public async Task> AddOrUpdateSubject([FromBody] SubjectCommand subjectCommand) { if (await _repository.AnyAsync(t => t.Id == subjectCommand.TrialId && !t.VisitPlanConfirmed)) diff --git a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs index 0fa6fd641..47fa11975 100644 --- a/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs +++ b/IRaCIS.Core.Domain/Common/FrontAuditConfig.cs @@ -99,6 +99,8 @@ namespace IRaCIS.Core.Domain.Models public string ConfigType { get; set; } + public int? Sort { get; set; } + } }