调整 CriterionNidus ReadingCriterionDictionary 维护sql 修改稽查表配置提交

Uat_Study
hang 2023-04-26 09:45:56 +08:00
parent 19ebce1c98
commit 6a7971f314
2 changed files with 190 additions and 42 deletions

View File

@ -0,0 +1,80 @@
--- 1、变更的表名
--EXEC sp_rename 'old_table_name', 'new_table_name';
EXEC sp_rename 'CriterionNidus', 'CriterionNidusSystem';
EXEC sp_rename 'ReadingCriterionDictionary', 'ReadingSystemCriterionDictionary';
---- 2、处理发布环境的表数据拆分
-- CriterionNidusSystem_copy
--SELECT *
--INTO CriterionNidusSystem_copy
--FROM CriterionNidusSystem
--WHERE IsSystemCriterion = 0;
--CriterionNidusTrial
SELECT *
INTO CriterionNidusTrial
FROM CriterionNidusSystem
WHERE IsSystemCriterion = 0;
SELECT *
INTO ReadingTrialCriterionDictionary
FROM ReadingSystemCriterionDictionary
WHERE IsSystemCriterion = 0;
----- 三、维护稽查数据
select Count(*) from DataInspection where EntityName='CriterionNidus'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Add'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Update'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Deleted'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Add/IsTrial'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Add/IsTrial/Auto'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Update/IsTrial'
select Count(*) from DataInspection where EntityName='CriterionNidus' and Identification='CriterionNidus/Deleted/IsTrial'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/QuestionType'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/LesionType'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/OncologyAssessType'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/GlobalAssessType'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/QuestionType/IsTrial'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/LesionType/IsTrial'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/OncologyAssessType/IsTrial'
select Count(*) from DataInspection where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/GlobalAssessType/IsTrial'
-- CriterionNidusSystem
update DataInspection SET Identification='CriterionNidusSystem/Add', EntityName='CriterionNidusSystem' where EntityName='CriterionNidus' and Identification='CriterionNidus/Add'
update DataInspection SET Identification='CriterionNidusSystem/Update' , EntityName='CriterionNidusSystem' where EntityName='CriterionNidus' and Identification='CriterionNidus/Update'
update DataInspection SET Identification='CriterionNidusSystem/Deleted', EntityName='CriterionNidusSystem' where EntityName='CriterionNidus' and Identification='CriterionNidus/Deleted'
-- CriterionNidusTrial
update DataInspection SET Identification='CriterionNidusTrial/Add' , EntityName='CriterionNidusTrial' where EntityName='CriterionNidus' and Identification='CriterionNidus/Add/IsTrial'
update DataInspection SET Identification='CriterionNidusTrial/Add/Auto' , EntityName='CriterionNidusTrial' where EntityName='CriterionNidus' and Identification='CriterionNidus/Add/IsTrial/Auto'
update DataInspection SET Identification='CriterionNidusTrial/Update' , EntityName='CriterionNidusTrial' where EntityName='CriterionNidus' and Identification='CriterionNidus/Update/IsTrial'
update DataInspection SET Identification='CriterionNidusTrial/Deleted' , EntityName='CriterionNidusTrial' where EntityName='CriterionNidus' and Identification='CriterionNidus/Deleted/IsTrial'
--ReadingSystemCriterionDictionary
update DataInspection SET Identification='ReadingSystemCriterionDictionary/Add/QuestionType', EntityName='ReadingSystemCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/QuestionType'
update DataInspection SET Identification='ReadingSystemCriterionDictionary/Add/LesionType' , EntityName='ReadingSystemCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/LesionType'
update DataInspection SET Identification='ReadingSystemCriterionDictionary/Add/OncologyAssessType', EntityName='ReadingSystemCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/OncologyAssessType'
update DataInspection SET Identification='ReadingSystemCriterionDictionary/Add/GlobalAssessType', EntityName='ReadingSystemCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/GlobalAssessType'
--ReadingTrialCriterionDictionary
update DataInspection SET Identification='ReadingTrialCriterionDictionary/Add/QuestionType', EntityName='ReadingTrialCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/QuestionType/IsTrial'
update DataInspection SET Identification='ReadingTrialCriterionDictionary/Add/LesionType' , EntityName='ReadingTrialCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/LesionType/IsTrial'
update DataInspection SET Identification='ReadingTrialCriterionDictionary/Add/OncologyAssessType', EntityName='ReadingTrialCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/OncologyAssessType/IsTrial'
update DataInspection SET Identification='ReadingTrialCriterionDictionary/Add/GlobalAssessType', EntityName='ReadingTrialCriterionDictionary' where EntityName='ReadingCriterionDictionary' and Identification='ReadingCriterionDictionary/Add/GlobalAssessType/IsTrial'

View File

@ -570,26 +570,38 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as CriterionNidusSystem; var entity = item.Entity as CriterionNidusSystem;
var extraIdentification = string.Empty;
if (entity.IsSystemCriterion == false)
{
extraIdentification = "/IsTrial";
if (_userInfo.RequestUrl != "OrganInfo/addOrUpdateCriterionNidus" && type == AuditOpt.Add)
{
extraIdentification = "/IsTrial/Auto";
}
}
await InsertInspection<CriterionNidusSystem>(entity, type, x => new InspectionConvertDTO() await InsertInspection<CriterionNidusSystem>(entity, type, x => new InspectionConvertDTO()
{ {
IsDistinctionInterface = false, IsDistinctionInterface = false,
ObjectRelationParentId = entity.CriterionId, ObjectRelationParentId = entity.CriterionId,
TrialReadingCriterionId = entity.IsSystemCriterion == false ? entity.CriterionId : null, });
}
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(CriterionNidusTrial)))
{
var type = GetEntityAuditOpt(item);
var entity = item.Entity as CriterionNidusTrial;
var extraIdentification = string.Empty;
if (_userInfo.RequestUrl != "OrganInfo/addOrUpdateCriterionNidus" && type == AuditOpt.Add)
{
extraIdentification = "/Auto";
}
await InsertInspection<CriterionNidusTrial>(entity, type, x => new InspectionConvertDTO()
{
IsDistinctionInterface = false,
ObjectRelationParentId = entity.CriterionId,
TrialReadingCriterionId = entity.CriterionId,
ExtraIndentification = extraIdentification ExtraIndentification = extraIdentification
@ -597,6 +609,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}); });
} }
//疗效评估 //疗效评估
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TumorAssessment_RECIST1Point1))) foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TumorAssessment_RECIST1Point1)))
@ -621,8 +634,6 @@ namespace IRaCIS.Core.Infra.EFCore.Common
if (entitys.Any(x => x.Entity.GetType() == typeof(ReadingSystemCriterionDictionary))) if (entitys.Any(x => x.Entity.GetType() == typeof(ReadingSystemCriterionDictionary)))
{ {
var type = AuditOpt.Add; var type = AuditOpt.Add;
var allList = entitys.Where(x => x.Entity.GetType() == typeof(ReadingSystemCriterionDictionary)).Select(t => t.Entity as ReadingSystemCriterionDictionary).ToList(); var allList = entitys.Where(x => x.Entity.GetType() == typeof(ReadingSystemCriterionDictionary)).Select(t => t.Entity as ReadingSystemCriterionDictionary).ToList();
@ -646,15 +657,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var extraIdentification = string.Empty; var extraIdentification = string.Empty;
//系统标准
if (cloneEntity.IsSystemCriterion) extraIdentification = $"/{cloneEntity.ParentCode}";
{
extraIdentification = $"/{cloneEntity.ParentCode}";
}
else
{
extraIdentification = $"/{cloneEntity.ParentCode}/IsTrial";
}
await InsertInspection<ReadingSystemCriterionDictionary>(cloneEntity, type, x => new InspectionConvertDTO() await InsertInspection<ReadingSystemCriterionDictionary>(cloneEntity, type, x => new InspectionConvertDTO()
@ -687,9 +692,70 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
if (entitys.Any(x => x.Entity.GetType() == typeof(ReadingTrialCriterionDictionary)))
{
var type = AuditOpt.Add;
var allList = entitys.Where(x => x.Entity.GetType() == typeof(ReadingTrialCriterionDictionary)).Select(t => t.Entity as ReadingTrialCriterionDictionary).ToList();
//查询出字典的Value ValueCN Des 保存
var dicIdList = allList.Select(t => t.DictionaryId).ToList();
var selectList = await _dbContext.Dictionary.Where(x => dicIdList.Contains(x.Id)).Select(t => new { t.Id, t.Value, t.ValueCN, t.Description, t.ShowOrder }).ToListAsync();
foreach (var list in allList.GroupBy(t => t.ParentCode))
{
var firstEntity = list.First();
var cloneEntity = list.First().Clone();
//保证Id 唯一
cloneEntity.Id = IdentifierHelper.CreateGuid(firstEntity.CriterionId.ToString(), firstEntity.ParentCode.ToString());
var extraIdentification = string.Empty;
extraIdentification = $"/{cloneEntity.ParentCode}/IsTrial";
await InsertInspection<ReadingTrialCriterionDictionary>(cloneEntity, type, x => new InspectionConvertDTO()
{
ObjectRelationParentId = x.CriterionId,
TrialReadingCriterionId = x.CriterionId,
//不显示区分接口 通过是否是系统字典 以及字典Code 区分
IsDistinctionInterface = false,
ExtraIndentification = extraIdentification
},
new
{
SelectList = selectList.Join(list, t => t.Id, u => u.DictionaryId, (t, u) =>
new
{
t.Value,
t.ValueCN,
t.Description,
t.ShowOrder,
u.IsBaseLineUse,
u.IsFollowVisitUse
}
).OrderBy(t => t.ShowOrder).ToList()
});
}
} }
@ -1693,7 +1759,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var entity = item.Entity as ReadingClinicalData; var entity = item.Entity as ReadingClinicalData;
var config= await _dbContext.ClinicalDataTrialSet.FindAsync(entity.ClinicalDataTrialSetId); var config = await _dbContext.ClinicalDataTrialSet.FindAsync(entity.ClinicalDataTrialSetId);
await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO() await InsertInspection<ReadingClinicalData>(item.Entity as ReadingClinicalData, type, x => new InspectionConvertDTO()
{ {
@ -1705,7 +1771,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
ObjectRelationParentId = entity.ClinicalDataTrialSetId, ObjectRelationParentId = entity.ClinicalDataTrialSetId,
//ObjectRelationParentId2 = x.IsVisit == false?x.ReadingId:null //ObjectRelationParentId2 = x.IsVisit == false?x.ReadingId:null
},new {FileCountViewStr= config?.ClinicalDataLevel==ClinicalLevel.Subject && config?.ClinicalUploadType==ClinicalUploadType.Table?"NA": entity.FileCount.ToString() }); }, new { FileCountViewStr = config?.ClinicalDataLevel == ClinicalLevel.Subject && config?.ClinicalUploadType == ClinicalUploadType.Table ? "NA" : entity.FileCount.ToString() });
} }
//阅片期计划 //阅片期计划
@ -1950,7 +2016,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
t.QuestionName, t.QuestionName,
QuestionId = t.Id, QuestionId = t.Id,
t.ShowOrder, t.ShowOrder,
AnswerType= t.Type, AnswerType = t.Type,
}) })
.OrderBy(t => t.ShowOrder).ToListAsync(); .OrderBy(t => t.ShowOrder).ToListAsync();
@ -1958,13 +2024,13 @@ namespace IRaCIS.Core.Infra.EFCore.Common
new new
{ {
//如果问题类型是附件 特殊处理 方便前端解析 //如果问题类型是附件 特殊处理 方便前端解析
Answer= u.AnswerType== "upload"? "❄❅❆❇❈❉❊" +t.Answer:t.Answer, Answer = u.AnswerType == "upload" ? "❄❅❆❇❈❉❊" + t.Answer : t.Answer,
u.QuestionName, u.QuestionName,
u.DictionaryCode, u.DictionaryCode,
u.ShowOrder, u.ShowOrder,
t.RowId t.RowId
} }
).OrderBy(t => t.RowId).ThenBy(t=>t.ShowOrder).ToList(); ).OrderBy(t => t.RowId).ThenBy(t => t.ShowOrder).ToList();
@ -1980,7 +2046,9 @@ namespace IRaCIS.Core.Infra.EFCore.Common
ExtraIndentification = extraIdentification, ExtraIndentification = extraIdentification,
}, new { QuestionAnswerList = taskQuestionAnswerList.Join(quesionList, t => t.ReadingQuestionTrialId, u => u.QuestionId, (t, u) => }, new
{
QuestionAnswerList = taskQuestionAnswerList.Join(quesionList, t => t.ReadingQuestionTrialId, u => u.QuestionId, (t, u) =>
new { Answer = u.AnswerType == "upload" ? "❄❅❆❇❈❉❊" + t.Answer : t.Answer, u.DictionaryCode, u.QuestionName, u.ShowOrder }).OrderBy(t => t.ShowOrder).ToList() new { Answer = u.AnswerType == "upload" ? "❄❅❆❇❈❉❊" + t.Answer : t.Answer, u.DictionaryCode, u.QuestionName, u.ShowOrder }).OrderBy(t => t.ShowOrder).ToList()
, ,
TableQuestionAndAnswerList = tableQuesionAndAnswerList TableQuestionAndAnswerList = tableQuesionAndAnswerList
@ -2167,7 +2235,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
var cloneEntity = firstEntity.Clone(); var cloneEntity = firstEntity.Clone();
var criterion = await _dbContext.VisitTask.Where(t => t.Id == cloneEntity.GlobalTaskId).Select(t => new { t.TrialReadingCriterionId,t.TrialReadingCriterion.CriterionType } ).FirstOrDefaultAsync(); var criterion = await _dbContext.VisitTask.Where(t => t.Id == cloneEntity.GlobalTaskId).Select(t => new { t.TrialReadingCriterionId, t.TrialReadingCriterion.CriterionType }).FirstOrDefaultAsync();
//保证Id 唯一 //保证Id 唯一
cloneEntity.Id = IdentifierHelper.CreateGuid(firstEntity.GlobalTaskId.ToString(), criterion.TrialReadingCriterionId.ToString()); cloneEntity.Id = IdentifierHelper.CreateGuid(firstEntity.GlobalTaskId.ToString(), criterion.TrialReadingCriterionId.ToString());
@ -2199,7 +2267,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
extraIdentification = "/PCWG3"; extraIdentification = "/PCWG3";
//获取访视的评估结果 也要记录稽查 //获取访视的评估结果 也要记录稽查
var visitAnswerList = await _dbContext.ReadingTaskQuestionAnswer.Where(t => t.VisitTaskId == group.Key &&t.ReadingQuestionTrial.GlobalReadingShowType != GlobalReadingShowType.NotShow).Select(u => new var visitAnswerList = await _dbContext.ReadingTaskQuestionAnswer.Where(t => t.VisitTaskId == group.Key && t.ReadingQuestionTrial.GlobalReadingShowType != GlobalReadingShowType.NotShow).Select(u => new
{ {
TaskBlindName = u.VisitTask.TaskBlindName, TaskBlindName = u.VisitTask.TaskBlindName,
QuestionId = u.ReadingQuestionTrialId, QuestionId = u.ReadingQuestionTrialId,
@ -2207,7 +2275,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
u.ReadingQuestionTrial.DictionaryCode, u.ReadingQuestionTrial.DictionaryCode,
u.ReadingQuestionTrial.ShowOrder, u.ReadingQuestionTrial.ShowOrder,
u.Answer u.Answer
}).OrderBy(t=>t.ShowOrder).ToListAsync(); }).OrderBy(t => t.ShowOrder).ToListAsync();
var obj = new var obj = new
@ -2259,7 +2327,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
VisitTaskId = x.GlobalTaskId, VisitTaskId = x.GlobalTaskId,
TrialReadingCriterionId = criterion.TrialReadingCriterionId, TrialReadingCriterionId = criterion.TrialReadingCriterionId,
ObjectRelationParentId = x.TaskId, ObjectRelationParentId = x.TaskId,
ExtraIndentification=extraIdentification ExtraIndentification = extraIdentification
}, new { GlobalAnswerList = objList }); }, new { GlobalAnswerList = objList });
} }
@ -2628,7 +2696,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
if (info == null) if (info == null)
{ {
var subject= _dbContext.Subject.Find(generalData.SubjectId); var subject = _dbContext.Subject.Find(generalData.SubjectId);
generalData.TrialId = subject?.TrialId; generalData.TrialId = subject?.TrialId;
generalData.SiteId = subject?.SiteId; generalData.SiteId = subject?.SiteId;