From 9ad11b16d1721621594f29df5cb73f5107a8c070 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 10 Oct 2024 16:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E7=BB=84=E6=88=96=E8=80=85PD=20=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A7=A6=E5=8F=91=E5=92=8C=E6=B6=88=E8=B4=B9?= =?UTF-8?q?=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 45 +++++ .../Consumer/ReadingRelationEmailConsumer.cs | 58 ++++++ .../Consumer/SiteSurverEmailConsumer.cs | 65 ++++--- .../SubjectVisitQCAndCheckConsumer.cs | 85 +++++++++ .../ReadingEnrollOrPDRelationEvent.cs | 41 +++++ .../_DomainEvent/SubjectStateChangedEvent.cs | 13 -- .../SubjectVisitStateChangedEvent.cs | 79 ++++++++ .../UserSiteSurveySubmitedEvent.cs | 32 ++-- .../Interceptor/AddDomainExt.cs | 168 +++++++++++++++++- 9 files changed, 513 insertions(+), 73 deletions(-) create mode 100644 IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs create mode 100644 IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs create mode 100644 IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs delete mode 100644 IRaCIS.Core.Domain/_DomainEvent/SubjectStateChangedEvent.cs create mode 100644 IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a53671bce..f01d2d437 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12727,6 +12727,21 @@ + + + 加急的医学反馈任务 通知MIM + + + + + MIM 回复医学返回通知IR + + + + + 加急阅片 IR 申请重阅 + + 用户提交 发送邮件 通知SPM 或者PM @@ -12742,6 +12757,36 @@ 调研表驳回发送邮件 之前已有,需要迁移过来 + + + CRC 提交了 通知QC进行质控 + + + + + CRC 回复质控质疑 通知QC + + + + + QC回复 质控质疑,通知CRC + + + + + CRC 回复一致性核查质疑 通知PM + + + + + PM 一致性核查 通知CRC + + + + + 通知PM 进行一致性核查 + + 参考链接:https://github.com/MassTransit/MassTransit/discussions/2498 diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs new file mode 100644 index 000000000..88020edea --- /dev/null +++ b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs @@ -0,0 +1,58 @@ +using IRaCIS.Core.Application.MassTransit.Command; +using IRaCIS.Core.Domain; +using IRaCIS.Core.Domain.BaseModel; +using MassTransit; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Application.MassTransit.Consumer; + +/// +/// 加急的医学反馈任务 通知MIM +/// +public class UrgentMedicalReviewAddedEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + +//IR 回复医学反馈通知MIM +public class UrgentIRRepliedMedicalReviewConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} +public class UrgentIRRepliedMedicalReview : DomainEvent +{ + public Guid ReadingMedicalReviewDialogId { get; set; } +} + +/// +/// MIM 回复医学返回通知IR +/// +public class UrgentMIMRepliedMedicalReviewConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + +/// +/// 加急阅片 IR 申请重阅 +/// +public class UrgentIRApplyedReReadingConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/SiteSurverEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/SiteSurverEmailConsumer.cs index 12179c962..3b9ad510e 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/SiteSurverEmailConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/SiteSurverEmailConsumer.cs @@ -8,41 +8,38 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IRaCIS.Core.Application.MassTransit.Consumer +namespace IRaCIS.Core.Application.MassTransit.Consumer; + +/// +/// 用户提交 发送邮件 通知SPM 或者PM +/// +public class UserSiteSurveySubmitedEventConsumer : IConsumer { - /// - /// 用户提交 发送邮件 通知SPM 或者PM - /// - public class UserSiteSurveySubmitedEventConsumer : IConsumer + public Task Consume(ConsumeContext context) { - public Task Consume(ConsumeContext context) - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); + } +} + +/// +/// 调研表初审通过,进行复审发送邮件 +/// +public class SiteSurveySPMSubmitedEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + +/// +/// 调研表驳回发送邮件 之前已有,需要迁移过来 +/// +public class SiteSurverRejectedEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); } - - /// - /// 调研表初审通过,进行复审发送邮件 - /// - public class SiteSurveySPMSubmitedEventConsumer : IConsumer - { - public Task Consume(ConsumeContext context) - { - throw new NotImplementedException(); - } - } - - - /// - /// 调研表驳回发送邮件 之前已有,需要迁移过来 - /// - public class SiteSurverRejectedEventConsumer : IConsumer - { - public Task Consume(ConsumeContext context) - { - throw new NotImplementedException(); - } - } - - } diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs new file mode 100644 index 000000000..8dd211249 --- /dev/null +++ b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs @@ -0,0 +1,85 @@ +using IRaCIS.Core.Application.MassTransit.Command; +using IRaCIS.Core.Domain; +using IRaCIS.Core.Domain.BaseModel; +using MassTransit; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Application.MassTransit.Consumer; + + +/// +/// CRC 提交了 通知QC进行质控 +/// +public class CRCSubmitedAndQCToAuditEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + +/// +/// CRC 回复质控质疑 通知QC +/// +public class CRCRepliedQCChallengeEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + +/// +/// QC回复 质控质疑,通知CRC +/// +public class QCRepliedQCChallengeEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + +/// +/// CRC 回复一致性核查质疑 通知PM +/// +public class CRCRepliedCheckChallengeEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + + +/// +/// PM 一致性核查 通知CRC +/// +public class PMRepliedCheckChallengeEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + + +/// +/// 通知PM 进行一致性核查 +/// +public class CheckStateChangedToAuditEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} + diff --git a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs new file mode 100644 index 000000000..a5975b2c5 --- /dev/null +++ b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs @@ -0,0 +1,41 @@ +using IRaCIS.Core.Domain.BaseModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Domain; + +/// +/// 加急的医学反馈任务 通知MIM +/// +public class UrgentMedicalReviewAddedEvent : DomainEvent +{ + public Guid VisitTaskId { get; set; } + public Guid MedicalReviewId { get; set; } + +} + +//IR 回复医学反馈通知MIM +public class UrgentIRRepliedMedicalReview : DomainEvent +{ + public Guid ReadingMedicalReviewDialogId { get; set; } +} + +/// +/// MIM 回复医学返回通知IR +/// +public class UrgentMIMRepliedMedicalReview : DomainEvent +{ + public Guid ReadingMedicalReviewDialogId { get; set; } +} + + +/// +/// 加急阅片 IR 申请重阅 +/// +public class UrgentIRApplyedReReading : DomainEvent +{ + public Guid VisitTaskId { get; set; } +} diff --git a/IRaCIS.Core.Domain/_DomainEvent/SubjectStateChangedEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/SubjectStateChangedEvent.cs deleted file mode 100644 index f95b27ff8..000000000 --- a/IRaCIS.Core.Domain/_DomainEvent/SubjectStateChangedEvent.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Domain._DomainEvent -{ - - - - -} diff --git a/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs new file mode 100644 index 000000000..30d6474af --- /dev/null +++ b/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs @@ -0,0 +1,79 @@ +using IRaCIS.Core.Domain.BaseModel; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IRaCIS.Core.Domain; + +/// +/// CRC 提交了 通知QC进行质控 +/// +public class CRCSubmitedAndQCToAuditEvent : DomainEvent +{ + public Guid SubjectVisitId { get; set; } + + +} + +/// +/// CRC 回复质控质疑 通知QC +/// +public class CRCRepliedQCChallengeEvent : DomainEvent +{ + public Guid QCChallengeDialogId { get; set; } + + public Guid TrialId { get; set; } + + public Guid SubjectVisitId { get; set; } + +} + +/// +/// QC回复 质控质疑,通知CRC +/// +public class QCRepliedQCChallengeEvent : DomainEvent +{ + public Guid QCChallengeDialogId { get; set; } + + public Guid TrialId { get; set; } + + public Guid SubjectVisitId { get; set; } + +} + + +/// +/// CRC 回复一致性核查质疑 通知PM +/// +public class CRCRepliedCheckChallengeEvent : DomainEvent +{ + public Guid CheckChallengeDialogId { get; set; } + + public Guid TrialId { get; set; } + + public Guid SubjectVisitId { get; set; } +} + +/// +/// CRC 回复一致性核查质疑 通知PM +/// +public class PMRepliedCheckChallengeEvent : DomainEvent +{ + public Guid CheckChallengeDialogId { get; set; } + + public Guid TrialId { get; set; } + + public Guid SubjectVisitId { get; set; } +} + +/// +/// 通知PM 进行一致性核查 +/// +public class CheckStateChangedToAuditEvent : DomainEvent +{ + public Guid SubjectVisitId { get; set; } + +} \ No newline at end of file diff --git a/IRaCIS.Core.Domain/_DomainEvent/UserSiteSurveySubmitedEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/UserSiteSurveySubmitedEvent.cs index b60d9385a..d40050d39 100644 --- a/IRaCIS.Core.Domain/_DomainEvent/UserSiteSurveySubmitedEvent.cs +++ b/IRaCIS.Core.Domain/_DomainEvent/UserSiteSurveySubmitedEvent.cs @@ -5,23 +5,21 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IRaCIS.Core.Domain +namespace IRaCIS.Core.Domain; + +public class UserSiteSurveySubmitedEvent:DomainEvent { - public class UserSiteSurveySubmitedEvent:DomainEvent - { - public Guid TrialSiteSurveyId { get; set; } - - } - - public class SiteSurveySPMSubmitedEvent : DomainEvent - { - public Guid TrialSiteSurveyId { get; set; } - - } - - public class SiteSurverRejectedEvent : DomainEvent - { - public Guid TrialSiteSurveyId { get; set; } - } + public Guid TrialSiteSurveyId { get; set; } } + +public class SiteSurveySPMSubmitedEvent : DomainEvent +{ + public Guid TrialSiteSurveyId { get; set; } + +} + +public class SiteSurverRejectedEvent : DomainEvent +{ + public Guid TrialSiteSurveyId { get; set; } +} diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs index 5aa9e8ad9..9c5d254ec 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs @@ -70,21 +70,173 @@ public static class DBContext_Ext //入组或者PD 才执行下面的逻辑 if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) { + var originSubmitState = entry.Property(p => p.SubmitState).OriginalValue; + var originAuditState = entry.Property(p => p.AuditState).OriginalValue; + var originCheckState = entry.Property(p => p.CheckState).OriginalValue; + //质控状态变为待审核的时候 + + if (originSubmitState == SubmitStateEnum.ToSubmit && subjectVisit.SubmitState == SubmitStateEnum.Submitted && + originAuditState == AuditStateEnum.None && subjectVisit.AuditState == AuditStateEnum.ToAudit + ) + { + subjectVisit.AddDomainEvent(new CRCSubmitedAndQCToAuditEvent() { SubjectVisitId = subjectVisit.Id }); + } + + //一致性核查通知PM发送邮件 + if (originCheckState == CheckStateEnum.None && subjectVisit.CheckState == CheckStateEnum.ToCheck + ) + { + subjectVisit.AddDomainEvent(new CheckStateChangedToAuditEvent() { SubjectVisitId = subjectVisit.Id }); + } + + + + //添加进记录 + eventStoreList.AddRange(subjectVisit.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); } - } + foreach (var entry in changeTracker.Entries()) + { + var qCChallengeDialog = entry.Entity; + + //跟踪的方式查询 不会查询数据库多次 + var findSubjectVisit = dbContext.SubjectVisit.Find(qCChallengeDialog.SubjectVisitId); + var findTrial = dbContext.Trial.Find(findSubjectVisit.TrialId); + + //入组或者PD 才执行下面的逻辑 + if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) + { + //CRC 针对质控质疑进行回复 + if (entry.State == EntityState.Added && qCChallengeDialog.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator) + { + qCChallengeDialog.AddDomainEvent(new CRCRepliedQCChallengeEvent() { QCChallengeDialogId = qCChallengeDialog.Id, SubjectVisitId = findSubjectVisit.Id, TrialId = findSubjectVisit.TrialId }); + } + //QC 针对质控质疑进行回复 + else if (entry.State == EntityState.Added && qCChallengeDialog.UserTypeEnum == UserTypeEnum.IQC) + { + qCChallengeDialog.AddDomainEvent(new QCRepliedQCChallengeEvent() { QCChallengeDialogId = qCChallengeDialog.Id, SubjectVisitId = findSubjectVisit.Id, TrialId = findSubjectVisit.TrialId }); + + } + + //添加进记录 + eventStoreList.AddRange(qCChallengeDialog.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); + } + + } + + foreach (var entry in changeTracker.Entries()) + { + var checkChallengeDialog = entry.Entity; + + //跟踪的方式查询 不会查询数据库多次 + var findSubjectVisit = dbContext.SubjectVisit.Find(checkChallengeDialog.SubjectVisitId); + var findTrial = dbContext.Trial.Find(findSubjectVisit.TrialId); + + //入组或者PD 才执行下面的逻辑 + if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) + { + //CRC 针对质控质疑进行回复 + if (entry.State == EntityState.Added && checkChallengeDialog.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator) + { + checkChallengeDialog.AddDomainEvent(new CRCRepliedCheckChallengeEvent() { CheckChallengeDialogId = checkChallengeDialog.Id, SubjectVisitId = findSubjectVisit.Id, TrialId = findSubjectVisit.TrialId }); + } + else if (entry.State == EntityState.Added && checkChallengeDialog.UserTypeEnum == UserTypeEnum.ProjectManager) + { + checkChallengeDialog.AddDomainEvent(new PMRepliedCheckChallengeEvent() { CheckChallengeDialogId = checkChallengeDialog.Id, SubjectVisitId = findSubjectVisit.Id, TrialId = findSubjectVisit.TrialId }); + } + + //添加进记录 + eventStoreList.AddRange(checkChallengeDialog.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); + } + + } + + + //医学审核任务 + foreach (var entry in changeTracker.Entries()) + { + var taskMedicalReview = entry.Entity; + + //跟踪的方式查询 不会查询数据库多次 + var findVisitTask = dbContext.VisitTask.Find(taskMedicalReview.VisitTaskId); + var findTrial = dbContext.Trial.Find(findVisitTask.TrialId); + + //入组或者PD 才执行下面的逻辑 + if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) + { + + if (entry.State == EntityState.Added) + { + taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId }); + } + + //添加进记录 + eventStoreList.AddRange(taskMedicalReview.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); + } + + } + + //医学反馈 + foreach (var entry in changeTracker.Entries()) + { + var readingMedicalReviewDialog = entry.Entity; + + //跟踪的方式查询 不会查询数据库多次 + var findVisitTask = dbContext.VisitTask.Find(readingMedicalReviewDialog.VisitTaskId); + var findTrial = dbContext.Trial.Find(findVisitTask.TrialId); + + //入组或者PD 才执行下面的逻辑 + if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) + { + if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.MIM) + { + readingMedicalReviewDialog.AddDomainEvent(new UrgentMIMRepliedMedicalReview() { ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); + } + else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) + { + readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); + } + + //添加进记录 + eventStoreList.AddRange(readingMedicalReviewDialog.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); + } + + } + + //任务 申请重阅ReReadingApplyState + + foreach (var entry in changeTracker.Entries()) + { + + var visitTask = entry.Entity; + + //跟踪的方式查询 不会查询数据库多次 + var findTrial = dbContext.Trial.Find(visitTask.TrialId); + + //入组或者PD 才执行下面的逻辑 + if (findTrial != null && findTrial.IsEnrollementQualificationConfirm && findTrial.IsPDProgressView) + { + var originReReadingApplyState = entry.Property(p => p.ReReadingApplyState).OriginalValue; + + if (originReReadingApplyState == ReReadingApplyState.Default && visitTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) + { + visitTask.AddDomainEvent(new UrgentIRApplyedReReading() { VisitTaskId = visitTask.Id }); + } + + //添加进记录 + eventStoreList.AddRange(visitTask.DomainEvents.Select(t => new EventStoreRecord() { EventType = t.GetType().Name, EventData = t.ToJsonStr() })); + } + + } + + #endregion - - - //跟随事务一起保存数据库 - dbContext.EventStoreRecord.AddRange(eventStoreList); + dbContext.EventStoreRecord.AddRange(eventStoreList); } - - #region 暂时废弃 /// /// 暂时废弃,没有场景使用 @@ -128,6 +280,4 @@ public static class DBContext_Ext #endregion - - } \ No newline at end of file