修改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

@ -14,7 +14,9 @@ namespace IRaCIS.Core.Application.Service
/// <param name="subjectVisitId"></param> /// <param name="subjectVisitId"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception> /// <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 (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator)
{ {
//添加的时候不验证 //添加的时候不验证
if (subjectVisitId != null) if (subjectVisitId != null)
@ -25,6 +27,8 @@ namespace IRaCIS.Core.Application.Service
throw new BusinessValidationFailedException("CRC 已提交影像,不能进行操作。"); throw new BusinessValidationFailedException("CRC 已提交影像,不能进行操作。");
} }
} }
}
//IQC 的时候 验证是不是当前领取人 //IQC 的时候 验证是不是当前领取人
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.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) 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(); var visitList = await _repository.Where<SubjectVisit>(t => t.SubjectId == subjectId).Select(t => new { t.VisitNum, t.EarliestScanDate, t.LatestScanDate, t.Id }).ToListAsync();

View File

@ -17,6 +17,8 @@ namespace IRaCIS.Core.Domain.Models
public class TrialSiteSurvey : Entity, IAuditUpdate, IAuditAdd,ISoftDelete 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; 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 // Qc 问题答案 // 特殊GeneralId
if (entitys.Any(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer))) 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 #endregion
@ -372,6 +225,123 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#region 已修改 #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 问题 //系统 Qc 问题
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCQuestion))) 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; 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() await InsertInspection<SubjectVisit>(item.Entity as SubjectVisit, type, x => new InspectionConvertDTO()
{ {
//Subject的信息 找离的最近的Subject稽查信息 //Subject的信息 找离的最近的Subject稽查信息
@ -727,7 +684,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectId = x.SubjectId, SubjectId = x.SubjectId,
SubjectVisitId = x.Id, SubjectVisitId = x.Id,
SiteId = x.SiteId, SiteId = x.SiteId,
Reason = reason,
}, },
//兼容之前的配置名 //兼容之前的配置名
@ -769,18 +725,29 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
if(entitys.Any(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));
//await InsertInspection<NoneDicomStudy>(item.Entity as NoneDicomStudy, type, x => new InspectionConvertDTO()
//{ //{
// ObjectRelationParentId = x.SubjectVisitId, // 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,
// 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; var generalId = (inspection.GeneralId != null && inspection.GeneralId != Guid.Empty) ? inspection.GeneralId : entityObj.Id;
inspection.GeneralId = generalId; inspection.GeneralId = generalId;
inspection.Identification = await GetInspectionRecordIdentificationAsync(entityObj, type, inspection.IsDistinctionInterface); inspection.Identification = await GetInspectionRecordIdentificationAsync(inspection, entityObj, type, inspection.IsDistinctionInterface);
//将实体对象属性 映射到稽查实体 //将实体对象属性 映射到稽查实体
MapEntityPropertyToAuditEntity(entityObj, inspection); MapEntityPropertyToAuditEntity(entityObj, inspection);
@ -1311,7 +1278,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// 获取稽查记录的标识符 部分业务会进行特殊处理 /// 获取稽查记录的标识符 部分业务会进行特殊处理
/// </summary> /// </summary>
/// <returns></returns> /// <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; var entityTypeName = entityObj.GetType().Name;
@ -1323,30 +1290,23 @@ namespace IRaCIS.Core.Infra.EFCore.Common
entityTypeName = "New/" + "UserSigned"; entityTypeName = "New/" + "UserSigned";
} }
dynamic entity; object entity;
switch (entityObj.GetType().Name) switch (entityObj.GetType().Name)
{ {
case nameof(QCChallengeDialog): //case nameof(QCChallengeDialog):
case nameof(QCChallenge): //case nameof(QCChallenge):
case nameof(CheckChallengeDialog): //case nameof(CheckChallengeDialog):
type = type + "/(" + _userInfo.UserTypeShortName + ")"; // type = type + "/(" + _userInfo.UserTypeShortName + ")";
break; // break;
case nameof(NoneDicomStudy):
switch (_userInfo.RequestUrl.ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
}
break;
case nameof(SystemBasicData): case nameof(SystemBasicData):
entity = entityObj as SystemBasicData; var basicData = entityObj as SystemBasicData;
type = type + (entity.ParentId == null ? "/parent" : string.Empty); type = type + (basicData.ParentId == null ? "/parent" : string.Empty);
break; break;
case nameof(Trial): case nameof(Trial):
entity = entityObj as Trial; var trial = entityObj as Trial;
Guid id = entity.Id; Guid id = trial.Id;
Trial oldentity = await _dbContext.Trial.Where(x => x.Id == id).FirstOrDefaultAsync(); Trial oldentity = await _dbContext.Trial.Where(x => x.Id == id).FirstOrDefaultAsync();
switch (_userInfo.RequestUrl.ToLower()) switch (_userInfo.RequestUrl.ToLower())
{ {
@ -1361,21 +1321,60 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break; break;
} }
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()) switch (_userInfo.RequestUrl.ToLower())
{ {
case "qcoperation/obtainorcancelqctask": case "qcoperation/closecheckchallenge":
type = type + "/" + entity.IsTake.ToString();
inspection.Reason = checkDialog.TalkContent.Substring(checkDialog.TalkContent.LastIndexOf(':') + 1);
break; 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": case "qcoperation/qcpassedorfailed":
try
{ type = type + "/" + (40 % (int)sv.AuditState).ToString();
type = type + "/" + (40 % (int)entity.AuditState).ToString();
} break;
catch (Exception)
{ //设置核查通过
} case "qcoperation/setcheckpass":
inspection.Reason = sv.ManualPassReason;
break;
//领取或者取消QC任务
case "qcoperation/obtainorcancelqctask":
type = type + "/" + sv.IsTake.ToString();
break; break;
//确认重阅 区分用户类型 //确认重阅 区分用户类型
@ -1388,12 +1387,31 @@ namespace IRaCIS.Core.Infra.EFCore.Common
} }
else else
{ {
//SPM
type = type + "/" + 2; type = type + "/" + 2;
} }
break; break;
} }
if(sv.CheckChallengeState==CheckChanllengeTypeEnum.CRCWaitPMReply|| sv.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply)
{
//发送对话 修改质疑状态 不需要区分接口
IsDistinctionInterface = false;
type = type + "/ModifyCheckChallengeState";
}
break; break;
case nameof(NoneDicomStudy):
switch (_userInfo.RequestUrl.ToLower())
{
case "nonedicomstudy/addorupdatenonedicomstudy":
type = type + "/(" + _userInfo.UserTypeShortName + ")";
break;
}
break;
//任务表
case nameof(VisitTask): case nameof(VisitTask):
var visitTask = entityObj as VisitTask; var visitTask = entityObj as VisitTask;
@ -1459,7 +1477,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break; break;
//重阅记录表
case nameof(VisitTaskReReading): case nameof(VisitTaskReReading):
var visitTaskReReading = entityObj as VisitTaskReReading; var visitTaskReReading = entityObj as VisitTaskReReading;
@ -1496,6 +1514,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
break; break;
//一致性分析规则
case nameof(TaskConsistentRule): case nameof(TaskConsistentRule):
var taskConsistentRule = entityObj as TaskConsistentRule; var taskConsistentRule = entityObj as TaskConsistentRule;