删除历史sql
parent
b9b095a19c
commit
14ec78a2fd
|
@ -965,7 +965,6 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
else
|
||||
{
|
||||
var taskQuery = _visitTaskRepository.Where(x => x.TrialId == inQuery.TrialId && x.DoctorUserId == _userInfo.Id && x.TaskState == TaskState.Effect && x.TrialReadingCriterionId == trialReadingCriterionId)
|
||||
// .Where(x=>x.Subject.ClinicalDataList.Any(c => c.IsSign && (c.ReadingId == x.SouceReadModuleId || c.ReadingId == x.SourceSubjectVisitId)))
|
||||
.Where(x => !x.Subject.IsDeleted).Where(x => (x.IsNeedClinicalDataSign && x.IsClinicalDataSign) || !x.IsNeedClinicalDataSign);
|
||||
|
||||
iRUnReadOut = new IRUnReadOutDto()
|
||||
|
|
|
@ -65,40 +65,7 @@ namespace IRaCIS.Core.Application.Triggers
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
// 触发临床数据
|
||||
//if (context.ChangeType == ChangeType.Added)
|
||||
//{
|
||||
// var cRCClinicalDatas = await _clinicalDataTrialSetRepository.Where(x => x.TrialId == context.Entity.TrialId && x.UploadRole == UploadRole.CRC && x.IsConfirm)
|
||||
|
||||
// .Select(x => new
|
||||
// {
|
||||
// x.Id,
|
||||
// x.ClinicalDataLevel,
|
||||
// }).ToListAsync();
|
||||
|
||||
// List<ReadingClinicalData> readingClinicals = new List<ReadingClinicalData>();
|
||||
// readingClinicals.AddRange(
|
||||
|
||||
// cRCClinicalDatas.WhereIf(!context.Entity.IsBaseLine, x => x.ClinicalDataLevel == ClinicalLevel.SubjectVisit).Select(x => new ReadingClinicalData()
|
||||
// {
|
||||
// ClinicalDataTrialSetId = x.Id,
|
||||
// IsVisit = true,
|
||||
// SubjectId = context.Entity.SubjectId,
|
||||
// ReadingId = context.Entity.Id,
|
||||
// TrialId = context.Entity.TrialId
|
||||
|
||||
// }).ToList()
|
||||
|
||||
// );
|
||||
|
||||
|
||||
// await _readingClinicalDataRepository.AddRangeAsync(readingClinicals);
|
||||
// await _readingClinicalDataRepository.SaveChangesAsync();
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
--同步重阅申请表结构后,再维护该字段
|
||||
|
||||
UPDATE VisitTaskReReading
|
||||
SET TrialId = VisitTask.TrialId
|
||||
FROM VisitTaskReReading
|
||||
INNER JOIN VisitTask ON VisitTaskReReading.OriginalReReadingTaskId = VisitTask.Id;
|
||||
|
||||
delete VisitTaskReReading where TrialId is NULL
|
||||
|
||||
|
||||
--数据库列字符串列 长度
|
||||
SELECT t.name AS table_name,
|
||||
c.name AS column_name,
|
||||
d.name AS constraint_name,
|
||||
ty.Name as typeName,
|
||||
c.max_length as length
|
||||
FROM sys.tables t
|
||||
INNER JOIN sys.columns c ON c.object_id = t.object_id
|
||||
LEFT JOIN sys.default_constraints d ON d.parent_object_id = c.object_id AND d.parent_column_id = c.column_id
|
||||
INNER JOIN sys.types ty on ty.system_type_id = c.system_type_id
|
||||
AND ty.name in ('nvarchar', 'varchar', 'char', 'nchar')
|
||||
WHERE c.max_length < 100 AND c.max_length > 0
|
||||
|
||||
--带维护sql 的查询
|
||||
|
||||
SELECT t.name AS table_name,
|
||||
c.name AS column_name,
|
||||
d.name AS constraint_name,
|
||||
ty.Name as typeName,
|
||||
c.max_length as length,
|
||||
'ALTER TABLE ' + QUOTENAME(t.name) + ' DROP CONSTRAINT [' + d.name + ']' AS drop_constraint_sql,
|
||||
CASE WHEN c.max_length = -1 THEN 'ALTER TABLE ' + QUOTENAME(t.name) + ' ALTER COLUMN ' + QUOTENAME(c.name) + ' NVARCHAR(MAX)' + CASE WHEN c.is_nullable = 1 THEN ' NULL' ELSE ' NOT NULL' END
|
||||
WHEN c.max_length > 0 AND c.max_length < 100 THEN 'ALTER TABLE ' + QUOTENAME(t.name) + ' ALTER COLUMN ' + QUOTENAME(c.name) + ' NVARCHAR(' + CAST(100 AS VARCHAR(10)) + ')' + CASE WHEN c.is_nullable = 1 THEN ' NULL' ELSE ' NOT NULL' END
|
||||
WHEN c.max_length = 8000 THEN 'ALTER TABLE ' + QUOTENAME(t.name) + ' ALTER COLUMN ' + QUOTENAME(c.name) + ' NVARCHAR(' + CAST(4000 AS VARCHAR(10)) + ')' + CASE WHEN c.is_nullable = 1 THEN ' NULL' ELSE ' NOT NULL' END
|
||||
ELSE 'ALTER TABLE ' + QUOTENAME(t.name) + ' ALTER COLUMN ' + QUOTENAME(c.name) + ' ' + ty.name + '(' + CAST(c.max_length AS VARCHAR(10)) + ')' + CASE WHEN c.is_nullable = 1 THEN ' NULL' ELSE ' NOT NULL' END
|
||||
END AS AlterColumnSQL,
|
||||
'ALTER TABLE ' + QUOTENAME(t.name) + ' ADD CONSTRAINT ' +'DF_'+t.name+ '_'+ c.name + ' DEFAULT ' + d.definition + ' FOR ' + QUOTENAME(c.name) AS add_constraint_sql
|
||||
FROM sys.tables t
|
||||
INNER JOIN sys.columns c ON c.object_id = t.object_id
|
||||
LEFT JOIN sys.default_constraints d ON d.parent_object_id = c.object_id AND d.parent_column_id = c.column_id
|
||||
INNER JOIN sys.types ty on ty.system_type_id = c.system_type_id
|
||||
AND ty.name in ('nvarchar', 'varchar', 'char', 'nchar')
|
||||
and (ty.name != 'nvarchar' or (ty.name = 'nvarchar' and (c.max_length = -1 or (c.max_length < 100 and c.max_length > 0))))
|
||||
|
||||
|
||||
|
||||
--修改默认约束名
|
||||
SELECT
|
||||
OBJECT_SCHEMA_NAME(dc.parent_object_id) AS schema_name,
|
||||
OBJECT_NAME(dc.parent_object_id) AS table_name,
|
||||
dc.name AS constraint_name,
|
||||
COL_NAME(dc.parent_object_id, dc.parent_column_id) AS column_name,
|
||||
CONCAT('EXEC sp_rename N''', dc.name, ''', N''DF_', OBJECT_NAME(dc.parent_object_id), '_', COL_NAME(dc.parent_object_id, dc.parent_column_id), '''') AS executable_sql
|
||||
FROM
|
||||
sys.default_constraints dc
|
||||
WHERE
|
||||
dc.is_system_named = 1 -- 只查询自动生成的系统默认约束
|
||||
AND dc.name NOT LIKE 'DF\[_%]\[_%]' ESCAPE '\'; -- 排除符合 "DF_表名_列名" 格式的约束名
|
||||
|
||||
SELECT
|
||||
sys.tables.name AS table_name,
|
||||
sys.columns.name AS column_name,
|
||||
sys.default_constraints.name AS constraint_name,
|
||||
'EXEC sp_rename N''' + sys.default_constraints.name + ''', N''DF_' + sys.tables.name + '_' + sys.columns.name + ''''
|
||||
AS executable_sql
|
||||
FROM sys.default_constraints
|
||||
INNER JOIN sys.tables ON sys.default_constraints.parent_object_id = sys.tables.object_id
|
||||
INNER JOIN sys.columns ON sys.default_constraints.parent_column_id = sys.columns.column_id AND sys.tables.object_id = sys.columns.object_id
|
||||
|
||||
|
||||
--修改主键
|
||||
SELECT
|
||||
OBJECT_NAME(i.object_id) AS '表名',
|
||||
COL_NAME(ic.object_id, ic.column_id) AS '列名',
|
||||
i.name AS '索引名',
|
||||
CONCAT('EXEC sp_rename ''', i.name, ''', ''PK_', OBJECT_NAME(i.object_id), '_',
|
||||
COL_NAME(ic.object_id, ic.column_id), '''')
|
||||
AS '修改索引名为 PK_表名_字段名',
|
||||
i.is_primary_key AS '是否主键'
|
||||
FROM
|
||||
sys.indexes i
|
||||
INNER JOIN
|
||||
sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
|
||||
WHERE
|
||||
(i.is_primary_key = 1 OR i.is_unique_constraint = 1)
|
||||
AND OBJECTPROPERTY(i.object_id, 'IsSystemTable') = 0
|
||||
AND OBJECTPROPERTY(i.object_id, 'IsMSShipped') = 0
|
||||
AND OBJECT_NAME(i.object_id) <> 'sysdiagrams';
|
||||
|
||||
|
||||
|
||||
---------------------------维护临床数据是否应用 之前默认都是应用 现在添加字段 把状态都改为应用
|
||||
update ClinicalDataTrialSet set IsApply=1
|
||||
|
||||
|
||||
--维护 删除临床数据配置,导致删除阅片期问题
|
||||
delete ReadingClinicalData
|
||||
from ReadingClinicalData
|
||||
INNER JOIN ReadModule on ReadingClinicalData.ReadingId = ReadModule.Id
|
||||
|
||||
|
||||
where not EXISTS (select Id from TrialClinicalDataSetCriterion where ReadModule.TrialReadingCriterionId =TrialClinicalDataSetCriterion.TrialReadingCriterionId)
|
|
@ -1,15 +0,0 @@
|
|||
-- 查询指定 code 的记录及其父项
|
||||
SELECT *
|
||||
FROM Dictionary
|
||||
WHERE code = 'BusinessModule'
|
||||
|
||||
UNION
|
||||
|
||||
-- 查询指定 code 的记录及其子项
|
||||
SELECT t.*
|
||||
FROM Dictionary t
|
||||
INNER JOIN (
|
||||
SELECT Id
|
||||
FROM Dictionary
|
||||
WHERE code = 'BusinessModule'
|
||||
) AS selected ON t.ParentId = selected.Id;
|
|
@ -1,188 +0,0 @@
|
|||
--- 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'
|
||||
|
||||
|
||||
|
||||
--国际化indication 维护
|
||||
UPDATE Trial SET IndicationEnum = CASE
|
||||
WHEN Indication = '肺癌' THEN 0
|
||||
WHEN Indication = '实体瘤' THEN 1
|
||||
WHEN Indication = '淋巴瘤' THEN 2
|
||||
WHEN Indication = '乳腺癌' THEN 3
|
||||
WHEN Indication = '白血病' THEN 4
|
||||
WHEN Indication = '胃癌' THEN 5
|
||||
WHEN Indication = '肝癌' THEN 6
|
||||
WHEN Indication = '骨髓癌' THEN 7
|
||||
WHEN Indication = '肠癌' THEN 8
|
||||
WHEN Indication = '前列腺癌' THEN 9
|
||||
WHEN Indication = '肾癌' THEN 10
|
||||
WHEN Indication = '宫颈癌' THEN 11
|
||||
WHEN Indication = '头颈部癌' THEN 12
|
||||
WHEN Indication = '卵巢癌' THEN 13
|
||||
WHEN Indication = '胆癌' THEN 14
|
||||
WHEN Indication = '食管癌' THEN 15
|
||||
WHEN Indication = '腹膜癌' THEN 16
|
||||
WHEN Indication = '上皮癌' THEN 17
|
||||
WHEN Indication = '黑色素瘤' THEN 18
|
||||
WHEN Indication = '甲状腺癌' THEN 19
|
||||
WHEN Indication = '输卵管癌' THEN 20
|
||||
WHEN Indication = '胰腺癌' THEN 21
|
||||
WHEN Indication = '膀胱癌' THEN 22
|
||||
WHEN Indication = '鼻咽癌' THEN 23
|
||||
WHEN Indication = '胶质瘤' THEN 24
|
||||
WHEN Indication = '子宫癌' THEN 25
|
||||
WHEN Indication = '尿道癌' THEN 26
|
||||
WHEN Indication = '软组织肉瘤' THEN 27
|
||||
WHEN Indication = '神经内分泌瘤' THEN 28
|
||||
WHEN Indication = '睾丸癌' THEN 29
|
||||
WHEN Indication = '骨肉瘤' THEN 30
|
||||
WHEN Indication = '间皮瘤' THEN 31
|
||||
WHEN Indication = '绒毛膜病' THEN 32
|
||||
WHEN Indication = '胃肠道间质瘤' THEN 33
|
||||
WHEN Indication = '骨癌' THEN 34
|
||||
WHEN Indication = '脑瘤' THEN 35
|
||||
WHEN Indication = '胸腺瘤' THEN 36
|
||||
WHEN IndicationTypeId = '437a81b3-c5ad-49fd-82a1-8f441c4ba8da' THEN 37
|
||||
WHEN IndicationTypeId = '433d9801-5fa0-42bb-604b-08d9c1232c4f' THEN 38
|
||||
WHEN IndicationTypeId = 'a5fdd212-a716-4df4-604c-08d9c1232c4f' THEN 39
|
||||
ELSE IndicationEnum
|
||||
END;
|
||||
|
||||
select DISTINCT IndicationEnum ,Indication from Trial
|
||||
|
||||
update Trial set Indication='' where IndicationEnum not in (37,38,39)
|
||||
|
||||
|
||||
-- 附加评估发布设置之前的默认值
|
||||
Update ReadingQuestionCriterionTrial set IsAdditionalAssessment=0,IsAutoCreate=1
|
||||
|
||||
--- 维护临床数据英文名称
|
||||
update clinicalDataSystemSet set clinicalDataSystemSet.ClinicalDataSetEnName=DictionaryChild.Value from Dictionary DictionaryChild
|
||||
inner join clinicalDataSystemSet on CONVERT(varchar(200),clinicalDataSystemSet.ClinicalDataSetEnum) =DictionaryChild.Code
|
||||
inner join Dictionary DictionaryParent on DictionaryParent.Id=DictionaryChild.ParentId
|
||||
where DictionaryParent.Code='ClinicalDataType'
|
||||
go
|
||||
|
||||
|
||||
update ClinicalDataTrialSet set ClinicalDataTrialSet.ClinicalDataSetEnName=clinicalDataSystemSet.ClinicalDataSetEnName from clinicalDataSystemSet
|
||||
inner join ClinicalDataTrialSet on ClinicalDataTrialSet.SystemClinicalDataSetId=clinicalDataSystemSet.Id
|
||||
|
||||
|
||||
|
||||
---------------维护项目器官表 将器官信息在项目表里面存冗余
|
||||
update OrganTrialInfo set
|
||||
OrganTrialInfo.PartEN=OrganInfo.PartEN ,
|
||||
OrganTrialInfo.Part=OrganInfo.Part,
|
||||
OrganTrialInfo.TULOC=OrganInfo.TULOC,
|
||||
OrganTrialInfo.TULOCEN=OrganInfo.TULOCEN,
|
||||
OrganTrialInfo.TULAT=OrganInfo.TULAT,
|
||||
OrganTrialInfo.TULATEN=OrganInfo.TULATEN,
|
||||
OrganTrialInfo.IsLymphNodes=OrganInfo.IsLymphNodes,
|
||||
OrganTrialInfo.IsCanEditPosition=OrganInfo.IsCanEditPosition,
|
||||
OrganTrialInfo.Classification=OrganInfo.Classification,
|
||||
OrganTrialInfo.ClassificationEN=OrganInfo.ClassificationEN,
|
||||
OrganTrialInfo.ShowOrder=OrganInfo.ShowOrder,
|
||||
OrganTrialInfo.OrganType=OrganInfo.OrganType
|
||||
from OrganInfo inner join OrganTrialInfo
|
||||
on OrganInfo.Id=OrganTrialInfo.OrganInfoId where OrganTrialInfo.OrganType is null
|
||||
|
||||
|
||||
|
||||
|
||||
update FrontAuditConfig set Identification='' where Identification is NULL
|
||||
|
||||
--新增字段
|
||||
|
||||
ALTER TABLE [dbo].[Trial] ADD [AttendedReviewerTypes] varchar(255) COLLATE Chinese_PRC_CI_AS DEFAULT '' NOT NULL
|
||||
GO
|
||||
|
||||
ALTER TABLE [dbo].[Trial] ADD [DeclarationTypes] varchar(255) COLLATE Chinese_PRC_CI_AS DEFAULT '' NOT NULL
|
||||
GO
|
||||
|
||||
|
||||
--维护sql
|
||||
UPDATE Trial SET AttendedReviewerTypes = '|' + CAST(AttendedReviewerType AS VARCHAR(10)) + '|'
|
||||
|
||||
update Trial set DeclarationTypes ='|' + (select Code from Dictionary where Id= Trial.DeclarationTypeId) + '|'
|
||||
|
||||
|
||||
--验证sql
|
||||
select DISTINCT AttendedReviewerType ,AttendedReviewerTypes, DeclarationTypeId, Dictionary.Code,DeclarationTypes,Dictionary.[Value] from Trial inner join Dictionary on Trial.DeclarationTypeId=Dictionary.Id
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
-- 20221223同步表数据
|
||||
-- Dictionary FrontAuditConfig Menu UserType UserTypeMenu ReadingQuestionSystem ReadingTableQuestionSystem OrganInfo ReadingQuestionCriterionSystem TumorAssessment
|
||||
-- 需要特别注意的表 CriterionNidus ReadingCriterionDictionary
|
||||
|
||||
select * from CriterionNidus where IsSystemCriterion=1
|
||||
select * from ReadingCriterionDictionary where IsSystemCriterion=1
|
||||
delete CriterionNidus where IsSystemCriterion=1
|
||||
delete ReadingCriterionDictionary where IsSystemCriterion=1
|
File diff suppressed because it is too large
Load Diff
|
@ -1,107 +0,0 @@
|
|||
|
||||
--无序维护sql
|
||||
update VisitTask set TaskBlindName='Follow Up '
|
||||
from VisitTask
|
||||
INNER join ReadingQuestionCriterionTrial on VisitTask.TrialReadingCriterionId=ReadingQuestionCriterionTrial.Id
|
||||
INNER join SubjectVisit on VisitTask.SourceSubjectVisitId=SubjectVisit.Id
|
||||
where SubjectVisit.IsBaseLine=0 and ReadingQuestionCriterionTrial.IsReadingTaskViewInOrder=0
|
||||
|
||||
|
||||
-- 有序维护sql
|
||||
update VisitTask set TaskBlindName='Follow-up '+ cast(sv.rn as varchar)
|
||||
from VisitTask
|
||||
join ReadingQuestionCriterionTrial on VisitTask.TrialReadingCriterionId=ReadingQuestionCriterionTrial.Id
|
||||
--join SubjectVisit on VisitTask.SourceSubjectVisitId=SubjectVisit.Id
|
||||
join ( select Id SubjectVisitId, IsBaseLine, ROW_NUMBER() over( partition by SubjectId order by VisitNum asc )-1 rn,VisitNum from SubjectVisit where IsLostVisit=0) sv on VisitTask.SourceSubjectVisitId=sv.SubjectVisitId
|
||||
where sv.IsBaseLine=0 and ReadingQuestionCriterionTrial.IsReadingTaskViewInOrder=1
|
||||
|
||||
update VisitTask set TaskBlindName='Baseline' from VisitTask
|
||||
join SubjectVisit on VisitTask.SourceSubjectVisitId=SubjectVisit.Id where SubjectVisit.IsBaseLine=1
|
||||
|
||||
update Dictionary set code =0 where Id='15bb5529-a6fe-439f-5196-08da179a7080'
|
||||
update Dictionary set code =1 where Id='0628d7be-afba-4471-5197-08da179a7080'
|
||||
update Dictionary set code =2 where Id='41bfec4b-dbfb-401d-5198-08da179a7080'
|
||||
update Dictionary set code =-1 where Id='1fac678d-69b6-41c3-5199-08da179a7080'
|
||||
go
|
||||
|
||||
|
||||
update ReadingQuestionCriterionTrial set DigitPlaces=DigitPlaces-1 where DigitPlaces is not null
|
||||
update ReadingQuestionCriterionTrial set DigitPlaces=-1 where DigitPlaces=3
|
||||
|
||||
|
||||
--2022 12 -9 同步
|
||||
-- Dictionary UserTypeMenu Menu FrontAuditConfig ReadingQuestionCriterionSystem ReadingTableQuestionSystem
|
||||
|
||||
|
||||
|
||||
--阅片标准维护
|
||||
update DataInspection set ObjectRelationParentId3 = (select top 1 TrialReadingCriterionId from SubjectUser where Id =DataInspection.GeneralId) where EntityName='SubjectUser'
|
||||
update DataInspection set ObjectRelationParentId2 = (select top 1 TrialReadingCriterionId from ReadingPeriodSet where Id =DataInspection.GeneralId) where EntityName='ReadingPeriodSet'
|
||||
update DataInspection set ObjectRelationParentId2 = (select top 1 TrialReadingCriterionId from ReadModule where Id =DataInspection.GeneralId) where EntityName='ReadModule'
|
||||
update DataInspection set ObjectRelationParentId2 = (select top 1 TrialReadingCriterionId from TaskConsistentRule where Id =DataInspection.GeneralId) where EntityName='TaskConsistentRule'
|
||||
update DataInspection set ObjectRelationParentId3 = (select top 1 TrialReadingCriterionId from VisitTask where Id =DataInspection.GeneralId) where EntityName='VisitTask'
|
||||
|
||||
update ReadingTableQuestionTrial set DictionaryCode='' where DictionaryCode is null
|
||||
|
||||
|
||||
|
||||
|
||||
--维护RowInfo的OrderMark
|
||||
|
||||
select * from ReadingTableAnswerRowInfo
|
||||
update ReadingTableAnswerRowInfo set ReadingTableAnswerRowInfo.OrderMark=ReadingQuestionTrial.OrderMark from ReadingQuestionTrial
|
||||
inner join ReadingTableAnswerRowInfo on ReadingTableAnswerRowInfo.QuestionId=ReadingQuestionTrial.Id
|
||||
|
||||
|
||||
|
||||
delete ReadingTableQuestionAnswer where TableQuestionId in (select id from ReadingTableQuestionTrial where QuestionMark=3)
|
||||
go
|
||||
delete ReadingTableQuestionTrial where QuestionMark=3
|
||||
go
|
||||
delete ReadingTableQuestionSystem where QuestionMark=3
|
||||
go
|
||||
|
||||
|
||||
------------------------------------2022-12-13----------------------------
|
||||
update ReadingQuestionSystem set DefaultValue=''
|
||||
update ReadingQuestionTrial set DefaultValue=''
|
||||
|
||||
----------删除之后要重新同步器官数据
|
||||
delete OrganInfo where SystemCriterionId='B0450000-9B8E-98FA-6658-08DA4DAB1FAC'
|
||||
delete OrganTrialInfo
|
||||
where (select count(1) as num from OrganInfo where OrganInfo.Id = OrganTrialInfo.OrganInfoId) = 0
|
||||
|
||||
|
||||
----2022-12-15
|
||||
Update Trial set BlindBaseLineName='Baseline',BlindFollowUpPrefix='Follow-up'
|
||||
update DataInspection set VisitTaskId = GeneralId where EntityName='VisitTask'
|
||||
|
||||
--发布之前备份 前后端代码和完整的数据库
|
||||
|
||||
--2022-12-17 维护稽查数据
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('OriginalReReadingTaskId":"',JsonDetail)+26,36) where EntityName='VisitTaskReReading'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='TaskMedicalReview'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='ReadingOncologyTaskInfo'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='ReadingMedicalReviewDialog'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='ReadingTaskQuestionAnswer'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='ReadingTableAnswerRowInfo'
|
||||
update DataInspection set VisitTaskId= substring(JsonDetail,CHARINDEX('VisitTaskId":"',JsonDetail)+14,36) where EntityName='ReadingMedicineQuestionAnswer'
|
||||
|
||||
update DataInspection set SubjectVisitId=null where EntityName='ReadModule'
|
||||
update DataInspection set TrialReadingCriterionId=(select TrialReadingCriterionId from VisitTask where Id =VisitTaskId) where VisitTaskId is not null and TrialReadingCriterionId is null
|
||||
|
||||
|
||||
--稽查bug 数据维护
|
||||
|
||||
update DataInspection set TrialReadingCriterionId= substring(JsonDetail,CHARINDEX('TrialCriterionId":"',JsonDetail)+19 +
|
||||
( DATALENGTH( left( cast([JsonDetail] as VARCHAR(2500)) ,charindex('TrialCriterionId":"',JsonDetail)) )
|
||||
-LEN ( left( cast([JsonDetail] as VARCHAR(2500)) ,charindex('TrialCriterionId":"',JsonDetail)) )
|
||||
),36) where EntityName='ReadingTableQuestionTrial'
|
||||
update DataInspection set TrialReadingCriterionId= substring(JsonDetail,CHARINDEX('ReadingQuestionCriterionTrialId":"',JsonDetail)+34,36) where EntityName='ReadingQuestionTrial'
|
||||
update DataInspection set TrialReadingCriterionId= GeneralId where EntityName='ReadingQuestionCriterionTrial'
|
||||
|
||||
--维护临床数据状态
|
||||
update ReadingClinicalData set IsSign=1 where EXISTS(select * from SubjectVisit where Id=ReadingId and IsBaseLine=1 and IsConfirmedClinicalData=1) and IsSign=0
|
||||
update ReadingClinicalData set ReadingClinicalDataState=3 where IsSign=1 and ReadingClinicalDataState!=3
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
-- 插入字典code
|
||||
|
||||
|
||||
declare @TrialCriterionId uniqueidentifier='54650000-3E2C-0016-75E6-08DB320098F3'
|
||||
|
||||
insert TrialCriterionDictionaryCode (Id,TrialCriterionId,Code,CreateTime,CreateUserId)
|
||||
select NEWID(),
|
||||
@TrialCriterionId,Code,'2020-01-01','00000000-0000-0000-0000-000000000000' from SystemCriterionDictionaryCode
|
||||
|
||||
inner join ReadingQuestionCriterionTrial on SystemCriterionDictionaryCode.SystemCriterionId=ReadingQuestionCriterionTrial.ReadingQuestionCriterionSystemId and ReadingQuestionCriterionTrial.Id=
|
||||
@TrialCriterionId
|
||||
|
||||
where Code not in (select Code from TrialCriterionDictionaryCode where TrialCriterionId=
|
||||
@TrialCriterionId)
|
||||
|
||||
-- 插入字典
|
||||
insert into ReadingCriterionDictionary (Id,CriterionId,DictionaryId,CreateTime,CreateUserId,IsSystemCriterion,ParentCode,IsBaseLineUse,IsFollowVisitUse)
|
||||
|
||||
select NEWID(), @TrialCriterionId,DictionaryId,'2020-01-01','00000000-0000-0000-0000-000000000000',0,ParentCode,IsBaseLineUse,IsFollowVisitUse from ReadingCriterionDictionary
|
||||
|
||||
inner join ReadingQuestionCriterionTrial on ReadingCriterionDictionary.CriterionId=ReadingQuestionCriterionTrial.ReadingQuestionCriterionSystemId and ReadingQuestionCriterionTrial.Id=
|
||||
@TrialCriterionId
|
||||
|
||||
where DictionaryId not in (select DictionaryId from ReadingCriterionDictionary where CriterionId=
|
||||
@TrialCriterionId)
|
|
@ -3,12 +3,12 @@
|
|||
https://www.cnblogs.com/cqpanda/p/16815263.html
|
||||
|
||||
|
||||
# dotnet ef migrations add 签名名字 -p 项目名 -c 上下文名 -o 迁移文件生成目录
|
||||
# dotnet ef migrations add 本地迁移名字 -p 项目名 -c 数据库上下文名 -o 迁移文件生成目录
|
||||
|
||||
1、生成迁移文件
|
||||
dotnet ef migrations add Initial -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations
|
||||
|
||||
2、撤销刚才生成的迁移文件
|
||||
2、撤销刚才生成的迁移文件(未更新到数据库的)
|
||||
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
3、将迁移文件更新到数据库
|
||||
|
@ -17,7 +17,7 @@ https://www.cnblogs.com/cqpanda/p/16815263.html
|
|||
4、查看已有迁移
|
||||
dotnet ef migrations list -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
5、撤销某次更新到数据库的迁移
|
||||
5、撤销某次更新到数据库的迁移(自动执行down 方法)
|
||||
dotnet ef database update 某次迁移的前一次迁移名称 -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue