Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
he 2025-11-10 09:35:33 +08:00
commit 46704d5299
1 changed files with 510 additions and 76 deletions

View File

@ -20,6 +20,7 @@ using NPOI.SS.Formula.Functions;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -111,7 +112,9 @@ public class RESIST_Lugano_TUFixed
new TUValueEnum(){TUValueType="01",TumorIdentificationSimple="TUMIDENT",TumorIdentificationFullName="Tumor Identification",TumorIdentificationResult="TARGET",TumorIdentificationResultType="TARGET"},
new TUValueEnum(){TUValueType="01",TumorIdentificationSimple="TUMIDENT",TumorIdentificationFullName="Tumor Identification",TumorIdentificationResult="NON-TARGET",TumorIdentificationResultType="NON-TARGET"},
new TUValueEnum(){TUValueType="01",TumorIdentificationSimple="TUMIDENT",TumorIdentificationFullName="Tumor Identification",TumorIdentificationResult="NEW",TumorIdentificationResultType="NEW"},
new TUValueEnum(){TUValueType="02",TumorIdentificationSimple="TUSPLIT",TumorIdentificationFullName="Tumor Split",TumorIdentificationResult="TARGET",TumorIdentificationResultType="TARGET"}
new TUValueEnum(){TUValueType="02",TumorIdentificationSimple="TUSPLIT",TumorIdentificationFullName="Tumor Split",TumorIdentificationResult="TARGET",TumorIdentificationResultType="TARGET"},
new TUValueEnum(){TUValueType="02",TumorIdentificationSimple="TUSPLIT",TumorIdentificationFullName="Tumor Split",TumorIdentificationResult="NON-TARGET",TumorIdentificationResultType="NON-TARGET"},
new TUValueEnum(){TUValueType="02",TumorIdentificationSimple="TUSPLIT",TumorIdentificationFullName="Tumor Split",TumorIdentificationResult="NEW",TumorIdentificationResultType="NEW"}
}
;
}
@ -303,7 +306,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
LesionList = t.LesionList.OrderBy(t => t.RowMark).Select(c => new TumorLessionInfo()
{
Id=c.Id,
Id = c.Id,
LessionType = c.ReadingQuestionTrial.LesionType,
LessionCode = c.RowMark,
SplitRowId = c.SplitRowId,
@ -430,7 +433,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
foreach (var lesion in task.LesionList)
foreach (var lesion in task.LesionList.OrderBy(t => t.LessionType))
{
#region tu 表处理部分
@ -444,38 +447,89 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
#endregion
#region tr 处理部分1 病灶状态和测量值
var targetMarks = new List<QuestionMark>() { QuestionMark.State };
if (lesion.LessionAnswerList.Any(t => t.QuestionMark == QuestionMark.IsLymph && t.QuestionValue == "1"))
foreach (var lessionAnswer in lesion.LessionAnswerList)
{
targetMarks.AddRange(new List<QuestionMark>() { QuestionMark.ShortAxis, });
}
else if (lesion.LessionAnswerList.FirstOrDefault(t => t.QuestionMark == QuestionMark.MajorAxis)?.QuestionValue.IsNotNullOrEmpty() == true)
{
targetMarks.AddRange(new List<QuestionMark>() { QuestionMark.MajorAxis });
var trLessionIndex = -1;
List<TRValueEnum> trValueList = new List<TRValueEnum>();
if (criterion.CriterionType == CriterionType.RECIST1Point1)
{
trLessionIndex = Get_Resist_TR_Lession_Index(lesion, lessionAnswer);
trValueList = RESIST_TRFixed.TRValueList;
}
else if (criterion.CriterionType == CriterionType.Lugano2014)
{
trLessionIndex = Get_Luganno_TR_Lession_Index(task, lesion, lessionAnswer);
trValueList = Lugano_TRFixed.TRValueList;
}
if (trLessionIndex != -1)
{
var tr = CreatNewTRExport(task, tr_subjectIndexNoDic, tu);
if (lessionAnswer.TranslateDicName.IsNotNullOrEmpty())
{
tr.OriginalMeasurements = translateDataList[lessionAnswer.TranslateDicName].Where(t => t.Code.ToLower() == lessionAnswer.QuestionValue?.ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
}
else
{
tr.OriginalMeasurements = lessionAnswer.QuestionValue;
}
tr.OriginalUnit = translateDataList["ValueUnit"].Where(t => t.Code.ToLower() == ((int?)lessionAnswer.Unit)?.ToString().ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
//填充固定信息
Fill_TR_IndexValue(tr, trLessionIndex, trValueList);
trList.Add(tr);
}
}
//状态 和长径、短径
foreach (var lessionAnswer in lesion.LessionAnswerList.Where(t => targetMarks.Any(c => c == t.QuestionMark)))
{
var tr = CreatNewTRExport(task, tr_subjectIndexNoDic, tu);
//填充固定信息
Fill_TR_Resist_Fixed_Value(tr, lessionAnswer, translateDataList, isEn_Us);
trList.Add(tr);
}
#region RECIST1Point1 废弃 tr 处理部分1 病灶状态和测量值
//var targetMarks = new List<QuestionMark>() { QuestionMark.State };
//if (lesion.LessionAnswerList.Any(t => t.QuestionMark == QuestionMark.IsLymph && t.QuestionValue == "1"))
//{
// targetMarks.AddRange(new List<QuestionMark>() { QuestionMark.ShortAxis, });
//}
//else if (lesion.LessionAnswerList.FirstOrDefault(t => t.QuestionMark == QuestionMark.MajorAxis)?.QuestionValue.IsNotNullOrEmpty() == true)
//{
// targetMarks.AddRange(new List<QuestionMark>() { QuestionMark.MajorAxis });
//}
////状态 和长径、短径
//foreach (var lessionAnswer in lesion.LessionAnswerList.Where(t => targetMarks.Any(c => c == t.QuestionMark)))
//{
// var tr = CreatNewTRExport(task, tr_subjectIndexNoDic, tu);
// //填充固定信息
// Fill_TR_Resist_Fixed_Value(tr, lessionAnswer, translateDataList, isEn_Us);
// trList.Add(tr);
//}
#endregion
}
foreach (var questionAnswer in task.QuestionAnswerList)
@ -483,12 +537,34 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
#region TR 处理部分2 访视级别,自动计算
var trValueTypeIndex = Get_Resist_TR_Visit_Index(task, questionAnswer);
var trValueTypeIndex = -1;
List<TRValueEnum> trValueList = new List<TRValueEnum>();
if (criterion.CriterionType == CriterionType.RECIST1Point1)
{
trValueTypeIndex = Get_Resist_TR_Visit_Index(task, questionAnswer);
trValueList = RESIST_TRFixed.TRValueList;
}
else if (criterion.CriterionType == CriterionType.Lugano2014)
{
trValueTypeIndex = Get_Lugano_TR_Visit_Index(task, questionAnswer);
trValueList = Lugano_TRFixed.TRValueList;
}
if (trValueTypeIndex != -1)
{
var tr = CreatNewTRExport(task, tr_subjectIndexNoDic);
//填充固定信息
Fill_TR_IndexValue(tr, trValueTypeIndex, trValueList);
if (questionAnswer.TranslateDicName.IsNotNullOrEmpty())
{
tr.OriginalMeasurements = translateDataList[questionAnswer.TranslateDicName].Where(t => t.Code.ToLower() == questionAnswer.QuestionValue?.ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
@ -501,8 +577,6 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
tr.OriginalUnit = translateDataList["ValueUnit"].Where(t => t.Code.ToLower() == ((int?)questionAnswer.Unit)?.ToString().ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
//填充固定信息
Fill_TR_IndexValue(tr, trValueTypeIndex, RESIST_TRFixed.TRValueList);
trList.Add(tr);
}
@ -515,13 +589,30 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
if (task.VisitNum > 0)
{
var rsValueTypeIndex = Get_Resist_RS_VisitFixed_Index(task, questionAnswer);
var rsValueTypeIndex = -1;
List<RSValueEnum> rsValueList = new List<RSValueEnum>();
if (criterion.CriterionType == CriterionType.RECIST1Point1)
{
rsValueTypeIndex = Get_Resist_RS_VisitFixed_Index(task, questionAnswer);
rsValueList = RESIST_RSFixed.RSValueList;
}
else if (criterion.CriterionType == CriterionType.Lugano2014)
{
trValueTypeIndex = Get_Lugano_RS_VisitFixed_Index(task, questionAnswer);
rsValueList = Lugano_RSFixed.RSValueList;
}
if (rsValueTypeIndex != -1)
{
var rs = CreatNewRSExport(task, questionAnswer, rs_subjectIndexNoDic, translateDataList, isEn_Us);
Fill_RS_IndexValue(rs, rsValueTypeIndex, RESIST_RSFixed.RSValueList);
Fill_RS_IndexValue(rs, rsValueTypeIndex, rsValueList);
if (questionAnswer.TranslateDicName.IsNotNullOrEmpty())
@ -745,6 +836,362 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return tu;
}
#region lugano
private int Get_Luganno_TR_Lession_Index(TumorExportBaseModel task, TumorLessionInfo lesion, TumorLessionAnswerInfo lessionAnswer)
{
var trValueTypeIndex = -1;
//非基线任务
if (task.VisitTaskNum > 0)
{
switch (lessionAnswer.QuestionMark)
{
case QuestionMark.MajorAxis:
trValueTypeIndex = 0;
break;
case QuestionMark.ShortAxis:
trValueTypeIndex = 1;
break;
case QuestionMark.PPD:
trValueTypeIndex = 2;
break;
case QuestionMark.State:
trValueTypeIndex = 3;
break;
case QuestionMark.SUVmax:
trValueTypeIndex = 4;
break;
//PPDFNAD
case QuestionMark.NadirPPD:
trValueTypeIndex = 5;
break;
//PRECNPPD
case QuestionMark.LowPPDAddPercent:
trValueTypeIndex = 6;
break;
//LDIFNAD
case QuestionMark.LowPPDLDi:
trValueTypeIndex = 7;
break;
//SDIFNAD
case QuestionMark.LowPPDSDi:
trValueTypeIndex = 8;
break;
//ABSCNLDI
case QuestionMark.LowPPDLDiAdded:
trValueTypeIndex = 9;
break;
//ABSCNSDI
case QuestionMark.LowPPDSDiAdded:
trValueTypeIndex = 10;
break;
//NADIR
case QuestionMark.LowPPDVisit:
trValueTypeIndex = 11;
break;
}
}
//基线任务
else
{
switch (lessionAnswer.QuestionMark)
{
case QuestionMark.MajorAxis:
trValueTypeIndex = 0;
break;
case QuestionMark.ShortAxis:
trValueTypeIndex = 1;
break;
case QuestionMark.PPD:
trValueTypeIndex = 2;
break;
case QuestionMark.State:
trValueTypeIndex = 3;
break;
case QuestionMark.SUVmax:
trValueTypeIndex = 4;
break;
}
}
return trValueTypeIndex;
}
private int Get_Lugano_TR_Visit_Index(TumorExportBaseModel task, TumorCommonQustionInfo questionAnswer)
{
var trValueTypeIndex = -1;
//非基线任务
if (task.VisitTaskNum > 0)
{
switch (questionAnswer.QuestionType)
{
//LIVESTAT
case QuestionType.LiverState:
trValueTypeIndex = 12;
break;
case QuestionType.SplenicTopPosition:
trValueTypeIndex = 13;
break;
case QuestionType.SplenicBottomPosition:
trValueTypeIndex = 14;
break;
case QuestionType.SpleenLength:
trValueTypeIndex = 15;
break;
case QuestionType.SplenicStatus:
trValueTypeIndex = 16;
break;
case QuestionType.ExistPET:
trValueTypeIndex = 17;
break;
case QuestionType.MediastinumSUVmax:
trValueTypeIndex = 18;
break;
case QuestionType.LiverSUVmax:
trValueTypeIndex = 19;
break;
case QuestionType.SUVmax:
trValueTypeIndex = 20;
break;
case QuestionType.SUVmaxLesion:
trValueTypeIndex = 21;
break;
case QuestionType.PET5PS:
trValueTypeIndex = 22;
break;
case QuestionType.UptakeChange:
trValueTypeIndex = 23;
break;
case QuestionType.EvidenceFocalFDG:
trValueTypeIndex = 24;
break;
case QuestionType.SPD:
trValueTypeIndex = 25;
break;
case QuestionType.SPDChange:
trValueTypeIndex = 26;
break;
case QuestionType.SplenoncusChange:
trValueTypeIndex = 27;
break;
case QuestionType.SplenoncusAdd:
trValueTypeIndex = 28;
break;
case QuestionType.SplenoncusDiameterChange:
trValueTypeIndex = 29;
break;
case QuestionType.LowestSplenoncusVisit:
trValueTypeIndex = 30;
break;
}
}
//基线任务
else
{
switch (questionAnswer.QuestionType)
{
//LIVESTAT
case QuestionType.LiverState:
trValueTypeIndex = 12;
break;
case QuestionType.SplenicTopPosition:
trValueTypeIndex = 13;
break;
case QuestionType.SplenicBottomPosition:
trValueTypeIndex = 14;
break;
case QuestionType.SpleenLength:
trValueTypeIndex = 15;
break;
case QuestionType.SplenicStatus:
trValueTypeIndex = 16;
break;
case QuestionType.ExistPET:
trValueTypeIndex = 17;
break;
case QuestionType.MediastinumSUVmax:
trValueTypeIndex = 18;
break;
case QuestionType.LiverSUVmax:
trValueTypeIndex = 19;
break;
case QuestionType.SUVmax:
trValueTypeIndex = 20;
break;
case QuestionType.SUVmaxLesion:
trValueTypeIndex = 21;
break;
case QuestionType.PET5PS:
trValueTypeIndex = 22;
break;
case QuestionType.EvidenceFocalFDG:
trValueTypeIndex = 24;
break;
case QuestionType.SPD:
trValueTypeIndex = 25;
break;
}
}
return trValueTypeIndex;
}
private int Get_Lugano_RS_VisitFixed_Index(TumorExportBaseModel task, TumorCommonQustionInfo questionAnswer)
{
var rsValueTypeIndex = -1;
switch (questionAnswer.QuestionType)
{
case QuestionType.TargetLesion:
rsValueTypeIndex = 0;
break;
case QuestionType.NoTargetLesion:
rsValueTypeIndex = 1;
break;
case QuestionType.NewLesions:
rsValueTypeIndex = 2;
break;
case QuestionType.LiverAssessment:
rsValueTypeIndex = 3;
break;
case QuestionType.SplenicEvaluation:
rsValueTypeIndex = 4;
break;
case QuestionType.CTandMRI:
rsValueTypeIndex = 5;
break;
case QuestionType.LastFDGPET:
rsValueTypeIndex = 6;
break;
case QuestionType.FDGPET:
rsValueTypeIndex = 7;
break;
case QuestionType.ImgOncology:
rsValueTypeIndex = 8;
break;
case QuestionType.Tumor:
rsValueTypeIndex = 3;
break;
}
return rsValueTypeIndex;
}
#endregion
private TR_Export Fill_TR_IndexValue(TR_Export tr, int trValueTypeIndex, List<TRValueEnum> TRValueList)
{
tr.ValueType = TRValueList[trValueTypeIndex].TRValueType;
tr.TumorAssessmentSimpleName = TRValueList[trValueTypeIndex].TumorAssessmentSimpleName;
tr.TumorAssessmentFullName = TRValueList[trValueTypeIndex].TumorAssessmentFullName;
return tr;
}
private TU_Export Fill_Resisit_Lugano_TUExport(TU_Export tu, TumorLessionInfo lesion)
{
var lesionTypeIndex = -1;
//分裂的病灶
if (lesion.SplitRowId != null && lesion.SplitRowId != Guid.Empty)
{
switch (lesion.LessionType)
{
case LesionType.TargetLesion:
lesionTypeIndex = 3;
break;
case LesionType.NonTargetLesions:
lesionTypeIndex = 4;
break;
case LesionType.NewLesions:
lesionTypeIndex = 5;
break;
}
}
else
{
switch (lesion.LessionType)
{
case LesionType.TargetLesion:
lesionTypeIndex = 0;
break;
case LesionType.NonTargetLesions:
lesionTypeIndex = 1;
break;
case LesionType.NewLesions:
lesionTypeIndex = 2;
break;
}
}
if (lesionTypeIndex != -1)
{
tu.ValueType = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TUValueType;
tu.TumorIdentificationSimple = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationSimple;
tu.TumorIdentificationFullName = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationFullName;
tu.TumorIdentificationResult = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationResult;
tu.TumorIdentificationResultType = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationResultType;
}
return tu;
}
#region Resist CDISC 文档逻辑
@ -779,10 +1226,43 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
rs.ValueType = RSValueList[rsValueTypeIndex].RSValueType;
rs.EfficacyEvaluationSimpleName = RSValueList[rsValueTypeIndex].EfficacyEvaluationSimpleName;
rs.EfficacyEvaluationName = RSValueList[rsValueTypeIndex].EfficacyEvaluationName;
return rs;
}
private int Get_Resist_TR_Lession_Index(TumorLessionInfo lesion, TumorLessionAnswerInfo lessionAnswer)
{
var trValueTypeIndex = -1;
if (lessionAnswer.QuestionMark == QuestionMark.State)
{
trValueTypeIndex = 1;
}
//淋巴结取短径
else if (lessionAnswer.QuestionMark == QuestionMark.ShortAxis && lesion.LessionAnswerList.Any(t => t.QuestionMark == QuestionMark.IsLymph && t.QuestionValue == "1"))
{
trValueTypeIndex = 0;
}
//非淋巴结 并且长径有值
else if (lessionAnswer.QuestionMark == QuestionMark.MajorAxis
&& lesion.LessionAnswerList.Any(t => t.QuestionMark == QuestionMark.IsLymph && t.QuestionValue == "0")
&& lesion.LessionAnswerList.FirstOrDefault(t => t.QuestionMark == QuestionMark.MajorAxis)?.QuestionValue.IsNotNullOrEmpty() == true)
{
trValueTypeIndex = 0;
}
return trValueTypeIndex;
}
private int Get_Resist_TR_Visit_Index(TumorExportBaseModel task, TumorCommonQustionInfo questionAnswer)
{
var trValueTypeIndex = -1;
@ -852,15 +1332,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return trValueTypeIndex;
}
private TR_Export Fill_TR_IndexValue(TR_Export tr, int trValueTypeIndex, List<TRValueEnum> TRValueList)
{
tr.ValueType = TRValueList[trValueTypeIndex].TRValueType;
tr.TumorAssessmentSimpleName = TRValueList[trValueTypeIndex].TumorAssessmentSimpleName;
tr.TumorAssessmentFullName = TRValueList[trValueTypeIndex].TumorAssessmentFullName;
return tr;
}
[Obsolete]
private TR_Export Fill_TR_Resist_Fixed_Value(TR_Export tr, TumorLessionAnswerInfo lessionAnswer, Dictionary<string, List<BasicDicSelectCopy>> translateDataList, bool isEn_Us)
{
var trValueTypeIndex = -1;
@ -890,6 +1362,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
trValueTypeIndex = 0;
tr.OriginalMeasurements = lessionAnswer.QuestionValue;
tr.OriginalUnit = translateDataList["ValueUnit"].Where(t => t.Code.ToLower() == ((int?)lessionAnswer.Unit)?.ToString().ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
}
@ -899,45 +1372,6 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return tr;
}
private TU_Export Fill_Resisit_Lugano_TUExport(TU_Export tu, TumorLessionInfo lesion)
{
var lesionTypeIndex = -1;
//分裂的病灶
if (lesion.SplitRowId != null)
{
lesionTypeIndex = 3;
}
else
{
switch (lesion.LessionType)
{
case LesionType.TargetLesion:
lesionTypeIndex = 0;
break;
case LesionType.NonTargetLesions:
lesionTypeIndex = 1;
break;
case LesionType.NewLesions:
lesionTypeIndex = 2;
break;
}
}
if (lesionTypeIndex != -1)
{
tu.ValueType = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TUValueType;
tu.TumorIdentificationSimple = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationSimple;
tu.TumorIdentificationFullName = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationFullName;
tu.TumorIdentificationResult = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationResult;
tu.TumorIdentificationResultType = RESIST_Lugano_TUFixed.TUValueList[lesionTypeIndex].TumorIdentificationResultType;
}
return tu;
}
#endregion