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 running Details

Test_IRC_Net8
he 2025-12-10 10:43:22 +08:00
commit 4a335d2a28
6 changed files with 153 additions and 34 deletions

View File

@ -1,15 +1,19 @@
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using FellowOakDicom.Imaging.LUT;
using IRaCIS.Application.Contracts;
using IRaCIS.Application.Interfaces;
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Migrations;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using MiniExcelLibs;
using MiniExcelLibs.OpenXml;
using Newtonsoft.Json;
using NPOI.HSSF.UserModel;
using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
@ -681,9 +685,45 @@ public static class ExcelExportHelper
if (itemDicName.IsNotNullOrEmpty())
{
var translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
var optionTypeEnumStr = iteObjDic.ContainsKey("OptionTypeEnum") ? iteObjDic["OptionTypeEnum"]?.ToString() : "0";
var translatedItemData = "";
//多选
if (optionTypeEnumStr == "1")
{
int[] enumValues = new int[0];
// 1. 反序列化 JSON 数组 (字符串枚举)
if (!itemValue.StartsWith("[") || !itemValue.EndsWith("]"))
{
enumValues = new int[1] { int.Parse(itemValue) };
}
else
{
enumValues = JsonConvert.DeserializeObject<int[]>(itemValue)?? new int[0];
}
// 2. 翻译每一项并输出逗号拼接字符串
translatedItemData = string.Join(",",
enumValues.Select(code =>
dynamicTranslateDataList[itemDicName]
.FirstOrDefault(t =>
string.Equals(code.ToString(),t.Code, StringComparison.OrdinalIgnoreCase)
) is var r && r != null
? (isEn_US ? r.Value : r.ValueCN)
: string.Empty
));
}
else
{
translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
}
row.GetCell(writeIndex).SetCellValue(translatedItemData);
}
else
{

View File

@ -3168,7 +3168,7 @@ namespace IRaCIS.Core.Application.Service.Common
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Lesion Type" : "病灶类型", QuestionValue = lession.LessionType, TranslateDicName = "LesionType" });
}
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName });
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, OptionTypeEnum = t.OptionTypeEnum, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName });
//有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题
var dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
@ -3316,14 +3316,14 @@ namespace IRaCIS.Core.Application.Service.Common
addLessionInfoList.Add(new CommonQuesionInfo() { QuestionId = Guid.Empty, QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName });
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
//有三部分组成 外层问题+ 固定列表格名称 + 动态的表格问题
dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList();
}
else
{
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, OptionTypeEnum = t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
//两部分组成 外层问题+ 动态的表格问题
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();
@ -3433,7 +3433,7 @@ namespace IRaCIS.Core.Application.Service.Common
var dynamicLessionInfoList = new List<CommonQuesionInfo>();
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionId = t.TableQuesionId,OptionTypeEnum=t.OptionTypeEnum, QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode });
//两部分组成 外层问题+ 动态的表格问题
dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList();

View File

@ -15,6 +15,8 @@ public class TumorCommonQustionInfo
//问题标识,肿瘤评估用于区分是什么问题
public QuestionType? QuestionType { get; set; }
public OptionType OptionTypeEnum { get; set; }
public Guid QuestionId { get; set; }
public string QuestionName { get; set; }
@ -51,6 +53,8 @@ public class TumorLessionAnswerInfo
{
public QuestionMark? QuestionMark { get; set; }
public OptionType OptionTypeEnum { get; set; }
//病灶Id
public Guid RowId { get; set; }

View File

@ -1,4 +1,5 @@
using IRaCIS.Application.Contracts;
using DocumentFormat.OpenXml.Spreadsheet;
using IRaCIS.Application.Contracts;
using IRaCIS.Application.Interfaces;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.ViewModel;
@ -10,7 +11,9 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using MiniExcelLibs.OpenXml;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using Org.BouncyCastle.Asn1.X509;
using System;
using System.Collections;
using System.Collections.Generic;
@ -226,6 +229,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
.Select(t => new IVUS_OCTBaseDto()
{
ResearchProgramNo = t.Trial.ResearchProgramNo,
TrialSiteCode = t.Subject.TrialSite.TrialSiteCode,
SubjectCode = t.Subject.Code,
UserName = t.DoctorUser.UserName,
ArmEnum = t.ArmEnum,
@ -278,6 +282,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
.Select(c => new TumorCommonQustionInfo()
{
QuestionType = c.ReadingQuestionTrial.QuestionType,
OptionTypeEnum = c.ReadingQuestionTrial.OptionTypeEnum,
QuestionId = c.ReadingQuestionTrial.Id,
QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName,
QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer,
@ -300,6 +305,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
{
RowId = k.RowId,
OptionTypeEnum = k.ReadingTableQuestionTrial.OptionTypeEnum,
TranslateDicName = k.ReadingTableQuestionTrial.DictionaryCode,
QuestionMark = k.ReadingTableQuestionTrial.QuestionMark,
TableQuesionId = k.ReadingTableQuestionTrial.Id,
@ -358,9 +364,12 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
#region 字典和各个表的数组准备
var dicNameList = new List<string>() { "ArmEnum", "ValueUnit" }
var dicNameList = taskList.SelectMany(t => t.QuestionAnswerList).Select(t => t.TranslateDicName)
.Union(taskList.SelectMany(t => t.LesionList).SelectMany(t => t.LessionAnswerList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(c => c.TranslateDicName))
.Union(new List<string>() { "ArmEnum", "ValueUnit" })
.Distinct().ToArray();
//翻译字典
var translateDataList = await _dictionaryService.GetBasicDataSelect(dicNameList);
@ -392,7 +401,9 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
//靶段
ivus.TARGETV = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault()?.QuestionValue ?? string.Empty;
var target = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault();
ivus.TARGETV = translateDataList[target?.TranslateDicName].Where(t => t.Code.ToLower() == target?.QuestionValue?.ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
var marks = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegmentRemarks).FirstOrDefault()?.QuestionValue ?? string.Empty;
@ -431,7 +442,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
ivus.TOTALPA = findStatLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.EEMSubtractLumenSum).FirstOrDefault()?.QuestionValue ?? string.Empty;
//冠状动脉粥样硬化体积百分比PAV
ivus.TOTALPA = findPAVLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.PAV).FirstOrDefault()?.QuestionValue ?? string.Empty;
ivus.PAV = findPAVLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.PAV).FirstOrDefault()?.QuestionValue ?? string.Empty;
ivusList.Add(ivus);
@ -477,19 +488,19 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
case QuestionMark.AvgFCT:
mark = "AVGFCT";
break;
case QuestionMark.MacrophageInfiltration:
case QuestionMark.MacrophageInfiltrationMeasurement:
mark = "MACRI";
break;
case QuestionMark.MacrophageExtensionAngle:
case QuestionMark.MacrophageInfiltrationAngle:
mark = "MIARC";
break;
case QuestionMark.Microchannels:
case QuestionMark.MicrochannelMeasurement:
mark = "MC";
break;
case QuestionMark.CholesterolCrystallization:
case QuestionMark.CholesterolCrystalMeasurement:
mark = "CCS";
break;
case QuestionMark.LumenArea:
case QuestionMark.LumenAreaMeasurement:
mark = "LUMEN";
break;
@ -498,7 +509,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
if (mark.IsNotNullOrEmpty())
{
var oct = CreatOCT(task, pNo);
var oct = CreatOCT(task, pNo, translateDataList);
// 测量标识 阅片人_斑块号_表格_行号
@ -509,8 +520,18 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
oct.TESTCD = mark;
// 测量参数值
if (lessionAnswer.TranslateDicName.IsNotNullOrEmpty())
{
oct.ORRES = translateDataList[lessionAnswer.TranslateDicName].Where(t => t.Code.ToLower() == lessionAnswer.QuestionValue?.ToString().ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
}
else
{
oct.ORRES = lessionAnswer?.QuestionValue ?? string.Empty;
}
// 测量值单位
oct.ORRESU = translateDataList["ValueUnit"].Where(t => t.Code.ToLower() == ((int?)lessionAnswer.Unit)?.ToString().ToLower()).Select(t => isEn_Us ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
@ -629,7 +650,7 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
if (findAngle != null)
{
var oct = CreatOCT(task, pNo);
var oct = CreatOCT(task, pNo, translateDataList);
// 测量标识
@ -697,15 +718,20 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
}
private OctExportDto CreatOCT(IVUS_OCTBaseDto task, string pNo)
private OctExportDto CreatOCT(IVUS_OCTBaseDto task, string pNo, Dictionary<string, List<BasicDicSelectCopy>> translateDataList)
{
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
var oct = _mapper.Map<OctExportDto>(task);
//靶段
//靶段
oct.TARGETV = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault()?.QuestionValue ?? string.Empty;
var target = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegment).FirstOrDefault();
oct.TARGETV = translateDataList[target?.TranslateDicName].Where(t => t.Code.ToLower() == target?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
var marks = task.QuestionAnswerList.Where(t => t.QuestionType == QuestionType.TargetSegmentRemarks).FirstOrDefault()?.QuestionValue ?? string.Empty;
@ -722,7 +748,44 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
&& t.LessionAnswerList.Any(t => t.QuestionMark == QuestionMark.PlaqueNumber && t.QuestionValue == pNo)).FirstOrDefault();
// 斑块类型
oct.PLATYPE = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.Undetermined).FirstOrDefault()?.QuestionValue ?? string.Empty;
var undetermined = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.Undetermined).FirstOrDefault();
if (undetermined?.OptionTypeEnum == OptionType.Multiple)
{
var qValue = undetermined?.QuestionValue;
int[] enumValues = new int[0];
// 1. 反序列化 JSON 数组 (字符串枚举)
if (!qValue.StartsWith("[") || !qValue.EndsWith("]"))
{
enumValues = new int[1] { int.Parse(qValue) };
}
else
{
enumValues = JsonConvert.DeserializeObject<int[]>(qValue) ?? new int[0];
}
// 2. 翻译每一项并输出逗号拼接字符串
var tValue = string.Join(",",
enumValues.Select(code =>
translateDataList[undetermined.TranslateDicName]
.FirstOrDefault(t =>
string.Equals(code.ToString(), t.Code, StringComparison.OrdinalIgnoreCase)
) is var r && r != null
? (isEn_US ? r.Value : r.ValueCN)
: string.Empty
));
oct.PLATYPE = tValue;
}
else
{
oct.PLATYPE = translateDataList[undetermined?.TranslateDicName].Where(t => t.Code.ToLower() == undetermined?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
}
// 匹配动脉段最小FCT
oct.MINFCT = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.MiniMumFCT).FirstOrDefault()?.QuestionValue ?? string.Empty;
// 平均最小FCT
@ -732,13 +795,19 @@ public class IVUS_OCTExportService(IRepository<ReadingQuestionCriterionTrial> _r
// 脂质角度最大值
oct.LAMAX = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.MaxAvgLipidAngle).FirstOrDefault()?.QuestionValue ?? string.Empty;
// 巨噬细胞浸润
oct.PLAMACRI = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.MacrophageInfiltration).FirstOrDefault()?.QuestionValue ?? string.Empty;
var macri = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.MacrophageInfiltration).FirstOrDefault();
oct.PLAMACRI = translateDataList[macri?.TranslateDicName].Where(t => t.Code.ToLower() == macri?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
// 巨噬细胞浸润角度
oct.PLAMIARC = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.MacrophageExtensionAngle).FirstOrDefault()?.QuestionValue ?? string.Empty;
// 微通道
oct.PLAMC = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.Microchannels).FirstOrDefault()?.QuestionValue ?? string.Empty;
var mc = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.Microchannels).FirstOrDefault();
oct.PLAMC = translateDataList[mc?.TranslateDicName].Where(t => t.Code.ToLower() == mc?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
// 胆固醇结晶
oct.PLACCS = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.CholesterolCrystallization).FirstOrDefault()?.QuestionValue ?? string.Empty;
var ccs = findLession?.LessionAnswerList.Where(t => t.QuestionMark == QuestionMark.CholesterolCrystallization).FirstOrDefault();
oct.PLACCS = translateDataList[ccs?.TranslateDicName].Where(t => t.Code.ToLower() == ccs?.QuestionValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty;
return oct;
}

View File

@ -1256,6 +1256,8 @@ namespace IRaCIS.Core.Application.Contracts
//问题标识,肿瘤评估用于区分是什么问题
public QuestionType? QuestionType { get; set; }
public OptionType OptionTypeEnum { get; set; }
public Guid QuestionId { get; set; }
public string QuestionName { get; set; }
@ -1421,6 +1423,7 @@ namespace IRaCIS.Core.Application.Contracts
public string TableName { get; set; }
#endregion
public OptionType OptionTypeEnum { get; set; }
public Guid TableQuesionId { get; set; }

View File

@ -246,6 +246,7 @@ namespace IRaCIS.Core.Application.Service
.OrderBy(k => k.ReadingQuestionTrial.ShowOrder)
.Select(c => new CommonQuesionInfo()
{
OptionTypeEnum=c.ReadingQuestionTrial.OptionTypeEnum,
QuestionType = c.ReadingQuestionTrial.QuestionType,
QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName,
QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer,
@ -286,6 +287,7 @@ namespace IRaCIS.Core.Application.Service
.Select(c => new CommonQuesionInfo()
{
QuestionType = c.ReadingQuestionTrial.QuestionType,
OptionTypeEnum=c.ReadingQuestionTrial.OptionTypeEnum,
QuestionId = c.ReadingQuestionTrial.Id,
QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName,
QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer,
@ -306,6 +308,7 @@ namespace IRaCIS.Core.Application.Service
CreateMap<ReadingTableQuestionAnswer, CommonLessionQuestionAnswerInfo>()
//.ForMember(o => o.LessionCode, t => t.MapFrom(u => u.Lesion.RowMark))
//.ForMember(o => o.LessionType, t => t.MapFrom(u => (int?)u.ReadingQuestionTrial.LesionType))
.ForMember(o => o.OptionTypeEnum, t => t.MapFrom(u => u.ReadingTableQuestionTrial.OptionTypeEnum))
.ForMember(o => o.ShowOrder, t => t.MapFrom(u => u.ReadingTableQuestionTrial.ShowOrder))
.ForMember(o => o.CustomUnit, t => t.MapFrom(u => u.ReadingTableQuestionTrial.CustomUnit))
.ForMember(o => o.Unit, t => t.MapFrom(u => u.ReadingTableQuestionTrial.Unit))