修改QC 质疑对话稽查 和一致性核查稽查

Uat_Study
hang 2022-08-29 17:22:21 +08:00
parent b9188d379d
commit 6a3b73007e
4 changed files with 238 additions and 213 deletions

View File

@ -51,7 +51,7 @@ namespace IRaCIS.Core.Application.Contracts
public async Task<IResponseOutput<NoneDicomStudyAddReturnDto>> AddOrUpdateNoneDicomStudy(NoneDicomStudyAddOrEdit addOrEditNoneDicomStudy)
{
await QCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, addOrEditNoneDicomStudy.SubjectVisitId);
await QCCommon.VerifyIsCRCSubmmitAsync(_repository, _userInfo, addOrEditNoneDicomStudy.SubjectVisitId);
await QCCommon.VerifyStudyImageDataAsync(_repository, addOrEditNoneDicomStudy.SubjectId, addOrEditNoneDicomStudy.SubjectVisitId, addOrEditNoneDicomStudy.ImageDate);

View File

@ -14,18 +14,22 @@ namespace IRaCIS.Core.Application.Service
/// <param name="subjectVisitId"></param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
public static async Task VerifyIsCRCSubmmitAsync(IRepository _repository, IUserInfo _userInfo, Guid? subjectVisitId=null)
public static async Task VerifyIsCRCSubmmitAsync(IRepository _repository, IUserInfo _userInfo, Guid? subjectVisitId = null)
{
//添加的时候不验证
if (subjectVisitId != null)
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator)
{
if (await _repository.AnyAsync<SubjectVisit>(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.Submitted &&
(!t.QCChallengeList.Any(u => u.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload))))
//添加的时候不验证
if (subjectVisitId != null)
{
throw new BusinessValidationFailedException("CRC 已提交影像,不能进行操作。");
if (await _repository.AnyAsync<SubjectVisit>(t => t.Id == subjectVisitId && t.SubmitState == SubmitStateEnum.Submitted &&
(!t.QCChallengeList.Any(u => u.ReuploadEnum == QCChanllengeReuploadEnum.QCAgreeUpload))))
{
throw new BusinessValidationFailedException("CRC 已提交影像,不能进行操作。");
}
}
}
//IQC 的时候 验证是不是当前领取人
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC)
{
@ -36,7 +40,7 @@ namespace IRaCIS.Core.Application.Service
}
public static async Task VerifyIsCanQCAsync(IRepository _repository,IUserInfo _userInfo, SubjectVisit? subjectVisit=null, Guid? subjectVisitId=null)
public static async Task VerifyIsCanQCAsync(IRepository _repository, IUserInfo _userInfo, SubjectVisit? subjectVisit = null, Guid? subjectVisitId = null)
{
if (subjectVisitId != null)
{
@ -51,7 +55,7 @@ namespace IRaCIS.Core.Application.Service
public static async Task VerifyStudyImageDataAsync(IRepository _repository, Guid subjectId, Guid subjectVisitId,DateTime imageDate)
public static async Task VerifyStudyImageDataAsync(IRepository _repository, Guid subjectId, Guid subjectVisitId, DateTime imageDate)
{
var visitList = await _repository.Where<SubjectVisit>(t => t.SubjectId == subjectId).Select(t => new { t.VisitNum, t.EarliestScanDate, t.LatestScanDate, t.Id }).ToListAsync();
@ -109,7 +113,7 @@ namespace IRaCIS.Core.Application.Service
svExpression = t => t.InPlan == false;
}
}
@ -216,7 +220,7 @@ namespace IRaCIS.Core.Application.Service
svExpression = t => t.SubjectVisit.InPlan == false;
}
}

View File

@ -16,7 +16,9 @@ namespace IRaCIS.Core.Domain.Models
[Table("TrialSiteSurvey")]
public class TrialSiteSurvey : Entity, IAuditUpdate, IAuditAdd,ISoftDelete
{
//public bool IsLocked { get; set; }=false;
//public bool IsLocked { get; set; }=false;
public TrialSiteSurveyEnum State { get; set; } = TrialSiteSurveyEnum.ToSubmit;

View File

@ -143,79 +143,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
// 中心调研表
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteSurvey)))
{
var entity = item.Entity as TrialSiteSurvey;
if (entity.TrialSite == null)
{
entity.TrialSite = await _dbContext.TrialSite.Where(x => x.SiteId == entity.SiteId && x.TrialId == entity.TrialId).FirstOrDefaultAsync();
}
if (entity.PreliminaryUser == null)
{
entity.PreliminaryUser = await _dbContext.User.Where(x => x.Id == entity.PreliminaryUserId).FirstOrDefaultAsync();
}
if (entity.ReviewerUser == null)
{
entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync();
}
await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, null, new
{
TrialSiteCode = entity.TrialSite.TrialSiteCode,
TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName,
Phone = entity.Phone,
Email = entity.Email,
PreliminaryUser = entity.PreliminaryUser == null ? "" : entity.PreliminaryUser.LastName + " / " + entity.PreliminaryUser.FirstName,
ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.LastName + " / " + entity.ReviewerUser.FirstName,
});
}
//质疑
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge)))
{
var entity = item.Entity as QCChallenge;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
var content = string.Empty;
if (type == "Add")
{
content = entity.Content;
}
await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO()
{
TrialId = x.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
ObjectRelationParentId = x.SubjectVisitId
}, new
{
ChallengeCode = entity.ChallengeCode,
AuditState = subjectvisit.AuditState,
TalkContent = content,
IsOverTime = entity.IsClosed ? entity.ClosedTime > entity.DeadlineTime : DateTime.Now > entity.DeadlineTime,
});
}
// 一致性核查文件
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile)))
{
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
{
CreateTime = x.CreateTime,
ObjectRelationParentId = x.TrialId
});
}
// Qc 问题答案 // 特殊GeneralId
if (entitys.Any(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)))
@ -286,85 +217,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
//一致性核查 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{
var entity = item.Entity as CheckChallengeDialog;
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
var reason = string.Empty;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closecheckchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
await InsertInspection<CheckChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = entity.SubjectVisitId,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
CreateTime = x.CreateTime,
//byzhouhang
ObjectRelationParentId = entity.SubjectVisitId,
}, new
{
CheckState = subjectvisit.CheckState,
RequestBackState = subjectvisit.RequestBackState,
CheckChallengeState = subjectvisit.CheckChallengeState,
});
}
// 质疑信息 // 特殊GeneralId
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog)))
{
var reason = string.Empty;
var entity = item.Entity as QCChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
break;
}
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
var qCChallenge = await _dbContext.QCChallenge.Where(x => x.Id == entity.QCChallengeId).FirstOrDefaultAsync();
subjectvisit = subjectvisit ?? new SubjectVisit();
qCChallenge = qCChallenge ?? new QCChallenge();
await InsertInspection<QCChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
GeneralId = qCChallenge.Id,
TrialId = subjectvisit.TrialId,
SubjectVisitId = x.SubjectVisitId,
SiteId = subjectvisit.SiteId,
SubjectId = subjectvisit.SubjectId,
SubjectVisitName = subjectvisit.VisitName,
BlindName = subjectvisit.BlindName,
Reason = reason,
//byzhouhang
ObjectRelationParentId = qCChallenge.Id,
}, new
{
AuditState = subjectvisit.AuditState,
ReuploadEnum = qCChallenge.ReuploadEnum,
Content = qCChallenge.Content,
DeadlineTime = qCChallenge.DeadlineTime,
IsOverTime = qCChallenge.IsClosed ? qCChallenge.ClosedTime > qCChallenge.DeadlineTime : DateTime.Now > qCChallenge.DeadlineTime,
IsClosed = qCChallenge.IsClosed
});
}
#endregion
@ -372,6 +225,123 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 已修改
//QC 质疑
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge)))
{
var entity = item.Entity as QCChallenge;
await InsertInspection<QCChallenge>(entity, type, x => new InspectionConvertDTO()
{
SubjectVisitId = x.SubjectVisitId,
ObjectRelationParentId = x.SubjectVisitId
}, new
{
IsOverTime = entity.IsClosed ? entity.ClosedTime > entity.DeadlineTime : DateTime.Now > entity.DeadlineTime,
});
}
// 质疑 对话
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallengeDialog)))
{
var entity = item.Entity as QCChallengeDialog;
await InsertInspection<QCChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
SubjectVisitId = x.SubjectVisitId,
//byzhouhang
ObjectRelationParentId = entity.QCChallengeId,
IsDistinctionInterface = false
});
}
//一致性核查 对话
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CheckChallengeDialog)))
{
var entity = item.Entity as CheckChallengeDialog;
//var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
//subjectvisit = subjectvisit ?? new SubjectVisit();
//var reason = string.Empty;
//switch (_userInfo.RequestUrl.ToLower())
//{
// case "qcoperation/closecheckchallenge":
// reason = entity.TalkContent.Substring(entity.TalkContent.LastIndexOf(':') + 1);
// break;
//}
await InsertInspection<CheckChallengeDialog>(entity, type, x => new InspectionConvertDTO()
{
SubjectVisitId = x.SubjectVisitId,
//byzhouhang
IsDistinctionInterface = false,
ObjectRelationParentId = entity.SubjectVisitId,
}
//, new
//{
// CheckState = subjectvisit.CheckState,
// RequestBackState = subjectvisit.RequestBackState,
// CheckChallengeState = subjectvisit.CheckChallengeState,
//}
);
}
// 一致性核查文件 是否需要单独一个表记录?
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(ConsistencyCheckFile)))
{
await InsertInspection<ConsistencyCheckFile>(item.Entity as ConsistencyCheckFile, type, x => new InspectionConvertDTO()
{
ObjectRelationParentId = x.TrialId
});
}
// 中心调研表
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialSiteSurvey)))
{
var entity = item.Entity as TrialSiteSurvey;
if (entity.TrialSite == null)
{
entity.TrialSite = await _dbContext.TrialSite.Where(x => x.SiteId == entity.SiteId && x.TrialId == entity.TrialId).FirstOrDefaultAsync();
}
if (entity.PreliminaryUser == null)
{
entity.PreliminaryUser = await _dbContext.User.Where(x => x.Id == entity.PreliminaryUserId).FirstOrDefaultAsync();
}
if (entity.ReviewerUser == null)
{
entity.ReviewerUser = await _dbContext.User.Where(x => x.Id == entity.ReviewerUserId).FirstOrDefaultAsync();
}
await InsertInspection<TrialSiteSurvey>(item.Entity as TrialSiteSurvey, type, x => new InspectionConvertDTO()
{
ObjectRelationParentId = entity.TrialSite.Id,
}, new
{
//TrialSiteCode = entity.TrialSite.TrialSiteCode,
//TrialSiteAliasName = entity.TrialSite.TrialSiteAliasName,
//Phone = entity.Phone,
//Email = entity.Email,
PreliminaryUser = entity.PreliminaryUser == null ? "" : entity.PreliminaryUser.FullName,
ReviewerUser = entity.ReviewerUser == null ? "" : entity.ReviewerUser.FullName,
});
}
// 既往手术史
@ -439,9 +409,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
//系统 Qc 问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion)))
{
@ -709,16 +676,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
var entity = item.Entity as SubjectVisit;
string reason = string.Empty;
if (_userInfo.RequestUrl.ToLower() == "qcoperation/setcheckpass")
{
reason = entity.ManualPassReason;
}
var subjectCode = entity.Subject?.Code;
await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
{
//Subject的信息 找离的最近的Subject稽查信息
@ -727,7 +684,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectId = x.SubjectId,
SubjectVisitId = x.Id,
SiteId = x.SiteId,
Reason = reason,
},
//兼容之前的配置名
@ -769,18 +725,29 @@ namespace IRaCIS.Core.Infra.EFCore.Common
});
}
if(entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
{
var list = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile));
//if(entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
//{
// var list = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).Select(t=>t.Entity);
// var first = list.First() as NoneDicomStudyFile;
// if(first.NoneDicomStudy == null)
// {
// first.NoneDicomStudy = _dbContext.NoneDicomStudy.Find(first.NoneDicomStudyId);
// }
// await InsertInspection<NoneDicomStudyFile>(first, type, x => new InspectionConvertDTO()
// {
// GeneralId=first.NoneDicomStudyId,
// SubjectVisitId= first.NoneDicomStudy.SubjectVisitId,
//await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO()
//{
// ObjectRelationParentId = x.SubjectVisitId,
// ObjectRelationParentId = x.NoneDicomStudyId,
//});
// });
}
//}
@ -1118,7 +1085,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id;
inspection.GeneralId = generalId;
inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface);
inspection.Identification = await GetInspectionRecordIdentificationAsync(inspection, entityObj, type, inspection.IsDistinctionInterface);
//将实体对象属性 映射到稽查实体
MapEntityPropertyToAuditEntity(entityObj, inspection);
@ -1311,7 +1278,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// 获取稽查记录的标识符 部分业务会进行特殊处理
/// </summary>
/// <returns></returns>
public async Task<string> GetInspectionRecordIdentificationAsync<T>(T entityObj, string type, bool IsDistinctionInterface = true)
public async Task<string> GetInspectionRecordIdentificationAsync<T>(InspectionConvertDTO inspection, T entityObj, string type, bool IsDistinctionInterface = true)
{
var entityTypeName = entityObj.GetType().Name;
@ -1323,30 +1290,23 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entityTypeName = "New/" + "UserSigned";
}
dynamic entity;
object entity;
switch (entityObj.GetType().Name)
{
case nameof(QCChallengeDialog):
case nameof(QCChallenge):
case nameof(CheckChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
//case nameof(QCChallengeDialog):
//case nameof(QCChallenge):
//case nameof(CheckChallengeDialog):
// type = type + "/(" + _userInfo.UserTypeShortName + ")";
// break;
case nameof(NoneDicomStudy):
switch (_userInfo.RequestUrl.ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
}
break;
case nameof(SystemBasicData):
entity = entityObj as SystemBasicData;
type = type + (entity.ParentId == null ? "/parent" : string.Empty);
var basicData = entityObj as SystemBasicData;
type = type + (basicData.ParentId == null ? "/parent" : string.Empty);
break;
case nameof(Trial):
entity = entityObj as Trial;
Guid id = entity.Id;
var trial = entityObj as Trial;
Guid id = trial.Id;
Trial oldentity = await _dbContext.Trial.Where(x => x.Id == id).FirstOrDefaultAsync();
switch (_userInfo.RequestUrl.ToLower())
{
@ -1361,21 +1321,60 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break;
}
break;
case nameof(SubjectVisit):
entity = entityObj as SubjectVisit;
// 对话消息区分用户类型
case nameof(CheckChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")";
var checkDialog = entityObj as CheckChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/obtainorcancelqctask":
type = type + "/" + entity.IsTake.ToString();
case "qcoperation/closecheckchallenge":
inspection.Reason = checkDialog.TalkContent.Substring(checkDialog.TalkContent.LastIndexOf(':') + 1);
break;
}
break;
// 对话消息区分用户类型
case nameof(QCChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")";
var dialog= entityObj as QCChallengeDialog;
switch (_userInfo.RequestUrl.ToLower())
{
case "qcoperation/closeqcchallenge":
inspection.Reason = dialog.TalkContent.Substring(dialog.TalkContent.LastIndexOf(':') + 1);
break;
}
break;
case nameof(SubjectVisit):
var sv = entityObj as SubjectVisit;
switch (_userInfo.RequestUrl.ToLower())
{
//待处理?
case "qcoperation/qcpassedorfailed":
try
{
type = type + "/" + (40 % (int)entity.AuditState).ToString();
}
catch (Exception)
{
}
type = type + "/" + (40 % (int)sv.AuditState).ToString();
break;
//设置核查通过
case "qcoperation/setcheckpass":
inspection.Reason = sv.ManualPassReason;
break;
//领取或者取消QC任务
case "qcoperation/obtainorcancelqctask":
type = type + "/" + sv.IsTake.ToString();
break;
//确认重阅 区分用户类型
@ -1388,12 +1387,31 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
else
{
//SPM
type = type + "/" + 2;
}
break;
}
if(sv.CheckChallengeState==CheckChanllengeTypeEnum.CRCWaitPMReply|| sv.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply)
{
//发送对话 修改质疑状态 不需要区分接口
IsDistinctionInterface = false;
type = type + "/ModifyCheckChallengeState";
}
break;
case nameof(NoneDicomStudy):
switch (_userInfo.RequestUrl.ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
}
break;
//任务表
case nameof(VisitTask):
var visitTask = entityObj as VisitTask;
@ -1459,7 +1477,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break;
//重阅记录表
case nameof(VisitTaskReReading):
var visitTaskReReading = entityObj as VisitTaskReReading;
@ -1496,6 +1514,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break;
//一致性分析规则
case nameof(TaskConsistentRule):
var taskConsistentRule = entityObj as TaskConsistentRule;