修改病灶排序

Test_IRC_Net8
hang 2025-11-07 14:41:01 +08:00
parent dff2e712ad
commit ca425c602b
1 changed files with 487 additions and 75 deletions

View File

@ -20,6 +20,7 @@ using NPOI.SS.Formula.Functions;
using NPOI.Util; using NPOI.Util;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -430,7 +431,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 表处理部分 #region tu 表处理部分
@ -444,38 +445,89 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
#endregion #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, }); 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 (lesion.LessionAnswerList.FirstOrDefault(t => t.QuestionMark == QuestionMark.MajorAxis)?.QuestionValue.IsNotNullOrEmpty() == true) else if (criterion.CriterionType == CriterionType.Lugano2014)
{ {
targetMarks.AddRange(new List<QuestionMark>() { QuestionMark.MajorAxis }); trLessionIndex = Get_Luganno_TR_Lession_Index(task, lesion, lessionAnswer);
trValueList = Lugano_TRFixed.TRValueList;
} }
//状态 和长径、短径 if (trLessionIndex != -1)
foreach (var lessionAnswer in lesion.LessionAnswerList.Where(t => targetMarks.Any(c => c == t.QuestionMark)))
{ {
var tr = CreatNewTRExport(task, tr_subjectIndexNoDic, tu); 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_Resist_Fixed_Value(tr, lessionAnswer, translateDataList, isEn_Us); Fill_TR_IndexValue(tr, trLessionIndex, trValueList);
trList.Add(tr); 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 #endregion
} }
foreach (var questionAnswer in task.QuestionAnswerList) foreach (var questionAnswer in task.QuestionAnswerList)
@ -483,7 +535,24 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
#region TR 处理部分2 访视级别,自动计算 #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) if (trValueTypeIndex != -1)
{ {
@ -501,8 +570,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; 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); trList.Add(tr);
} }
@ -515,13 +582,30 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
if (task.VisitNum > 0) 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) if (rsValueTypeIndex != -1)
{ {
var rs = CreatNewRSExport(task, questionAnswer, rs_subjectIndexNoDic, translateDataList, isEn_Us); 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()) if (questionAnswer.TranslateDicName.IsNotNullOrEmpty())
@ -745,6 +829,347 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return tu; 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)
{
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;
}
#region Resist CDISC 文档逻辑 #region Resist CDISC 文档逻辑
@ -779,10 +1204,43 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
rs.ValueType = RSValueList[rsValueTypeIndex].RSValueType; rs.ValueType = RSValueList[rsValueTypeIndex].RSValueType;
rs.EfficacyEvaluationSimpleName = RSValueList[rsValueTypeIndex].EfficacyEvaluationSimpleName; rs.EfficacyEvaluationSimpleName = RSValueList[rsValueTypeIndex].EfficacyEvaluationSimpleName;
rs.EfficacyEvaluationName = RSValueList[rsValueTypeIndex].EfficacyEvaluationName; rs.EfficacyEvaluationName = RSValueList[rsValueTypeIndex].EfficacyEvaluationName;
return rs; 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) private int Get_Resist_TR_Visit_Index(TumorExportBaseModel task, TumorCommonQustionInfo questionAnswer)
{ {
var trValueTypeIndex = -1; var trValueTypeIndex = -1;
@ -852,15 +1310,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return trValueTypeIndex; return trValueTypeIndex;
} }
private TR_Export Fill_TR_IndexValue(TR_Export tr, int trValueTypeIndex, List<TRValueEnum> TRValueList) [Obsolete]
{
tr.ValueType = TRValueList[trValueTypeIndex].TRValueType;
tr.TumorAssessmentSimpleName = TRValueList[trValueTypeIndex].TumorAssessmentSimpleName;
tr.TumorAssessmentFullName = TRValueList[trValueTypeIndex].TumorAssessmentFullName;
return tr;
}
private TR_Export Fill_TR_Resist_Fixed_Value(TR_Export tr, TumorLessionAnswerInfo lessionAnswer, Dictionary<string, List<BasicDicSelectCopy>> translateDataList, bool isEn_Us) private TR_Export Fill_TR_Resist_Fixed_Value(TR_Export tr, TumorLessionAnswerInfo lessionAnswer, Dictionary<string, List<BasicDicSelectCopy>> translateDataList, bool isEn_Us)
{ {
var trValueTypeIndex = -1; var trValueTypeIndex = -1;
@ -890,6 +1340,7 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
trValueTypeIndex = 0; trValueTypeIndex = 0;
tr.OriginalMeasurements = lessionAnswer.QuestionValue; 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; 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 +1350,6 @@ public class Tumor_CDISC_ExportService(IRepository<ReadingQuestionCriterionTrial
return tr; 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 #endregion