添加重阅复制的逻辑
parent
7d88f49e68
commit
8de44fb7b3
|
|
@ -956,6 +956,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
|
|
||||||
public class CopyTableAnswerRowInfo : ReadingTableAnswerRowInfoBase
|
public class CopyTableAnswerRowInfo : ReadingTableAnswerRowInfoBase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public Guid? IdentityRowId { get; set; }
|
||||||
|
|
||||||
public Guid OriginalId { get; set; }
|
public Guid OriginalId { get; set; }
|
||||||
|
|
||||||
public LesionType? LesionType { get; set; }
|
public LesionType? LesionType { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -3078,6 +3078,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
//await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.RowId == (inDto.RowId ?? default(Guid)));
|
//await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.RowId == (inDto.RowId ?? default(Guid)));
|
||||||
//await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.Id == (inDto.RowId ?? default(Guid)));
|
//await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.Id == (inDto.RowId ?? default(Guid)));
|
||||||
_mapper.Map(inDto, rowInfo);
|
_mapper.Map(inDto, rowInfo);
|
||||||
|
rowInfo.IdentityRowId = rowInfo.IdentityRowId == null ? NewId.NextGuid() : rowInfo.IdentityRowId;
|
||||||
rowInfo.Id = inDto.RowId == null ? NewId.NextGuid() : inDto.RowId.Value;
|
rowInfo.Id = inDto.RowId == null ? NewId.NextGuid() : inDto.RowId.Value;
|
||||||
result.RowId = rowInfo.Id;
|
result.RowId = rowInfo.Id;
|
||||||
rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd;
|
rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using IRaCIS.Core.Application.Helper;
|
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
|
||||||
|
using IRaCIS.Core.Application.Helper;
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Domain.Models;
|
using IRaCIS.Core.Domain.Models;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
|
@ -16,6 +17,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
{
|
{
|
||||||
public class GeneralCalculateService(IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
public class GeneralCalculateService(IRepository<ReadingTableQuestionAnswer> _readingTableQuestionAnswerRepository,
|
||||||
IRepository<VisitTask> _visitTaskRepository,
|
IRepository<VisitTask> _visitTaskRepository,
|
||||||
|
IRepository<ReadingTaskQuestionMark> _readingTaskQuestionMarkRepository,
|
||||||
|
IRepository<ReadingNoneDicomMark> _readingNoneDicomMarkRepository,
|
||||||
|
IRepository<ReadingNoneDicomMarkBinding> _readingNoneDicomMarkBindingRepository,
|
||||||
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
|
||||||
ILogger<GeneralCalculateService> _logger,
|
ILogger<GeneralCalculateService> _logger,
|
||||||
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
|
||||||
|
|
@ -208,6 +212,175 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
return questions;
|
return questions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 复制既往新病灶答案
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task CopyHistoryAnswer(VisitTask taskinfo, List<ReadingTableAnswerRowInfo> tableRowList,List<ReadingTableQuestionAnswer> tableAnswerList)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (taskinfo.IsCopyLesionAnswer)
|
||||||
|
{
|
||||||
|
var historyTaskId = await _visitTaskRepository.Where(x =>
|
||||||
|
x.ReadingCategory == ReadingCategory.Visit &&
|
||||||
|
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||||
|
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
|
||||||
|
x.DoctorUserId == taskinfo.DoctorUserId &&
|
||||||
|
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
|
||||||
|
x.SubjectId == taskinfo.SubjectId &&
|
||||||
|
x.ReadingTaskState == ReadingTaskState.HaveSigned &&
|
||||||
|
x.VisitTaskNum == taskinfo.VisitTaskNum &&
|
||||||
|
x.TaskState != TaskState.Effect &&
|
||||||
|
x.ArmEnum == taskinfo.ArmEnum)
|
||||||
|
.OrderByDescending(x => x.SignTime)
|
||||||
|
.Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
// 1.标记信息复制有问题 2. 标记
|
||||||
|
|
||||||
|
if (historyTaskId != Guid.Empty)
|
||||||
|
{
|
||||||
|
var historyTableRowList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
var historyTableAnswerList = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
var answerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
|
||||||
|
|
||||||
|
var questionMarkList=await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
var noneDicomMarkList=await _readingNoneDicomMarkRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
var noneDicomMarkBindingList=await _readingNoneDicomMarkBindingRepository.Where(x => x.VisitTaskId == historyTaskId).ToListAsync();
|
||||||
|
|
||||||
|
foreach (var item in tableRowList)
|
||||||
|
{
|
||||||
|
var historyRow = historyTableRowList.Where(x =>
|
||||||
|
x.QuestionId == item.QuestionId &&
|
||||||
|
x.RowIndex == item.RowIndex &&
|
||||||
|
x.IdentityRowId==item.IdentityRowId &&
|
||||||
|
x.IdentityRowId !=null &&
|
||||||
|
x.OrganInfoId==item.OrganInfoId
|
||||||
|
).FirstOrDefault();
|
||||||
|
|
||||||
|
if (historyRow != null)
|
||||||
|
{
|
||||||
|
item.StudyId= historyRow.StudyId;
|
||||||
|
item.SeriesId= historyRow.SeriesId;
|
||||||
|
item.InstanceId= historyRow.InstanceId;
|
||||||
|
|
||||||
|
item.OtherStudyId = historyRow.OtherStudyId;
|
||||||
|
item.OtherSeriesId = historyRow.OtherSeriesId;
|
||||||
|
item.OtherInstanceId= historyRow.OtherInstanceId;
|
||||||
|
|
||||||
|
item.MeasureData= historyRow.MeasureData.Replace(historyTaskId.ToString(),taskinfo.Id.ToString());
|
||||||
|
item.OtherMeasureData = historyRow.OtherMeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString());
|
||||||
|
|
||||||
|
|
||||||
|
tableAnswerList.Where(x => x.RowId == item.Id).ForEach(x =>
|
||||||
|
{
|
||||||
|
x.Answer = x.Answer.IsNotNullOrEmpty() ?
|
||||||
|
historyTableAnswerList.Where(y => y.RowId == historyRow.Id && y.TableQuestionId == x.TableQuestionId).Select(x => x.Answer).FirstOrDefault()??string.Empty :
|
||||||
|
x.Answer;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制外层问题
|
||||||
|
answerList.ForEach(x =>
|
||||||
|
{
|
||||||
|
x.Id = NewId.NextGuid();
|
||||||
|
x.VisitTaskId = taskinfo.Id;
|
||||||
|
});
|
||||||
|
|
||||||
|
await _readingTaskQuestionAnswerRepository.AddRangeAsync(answerList);
|
||||||
|
|
||||||
|
|
||||||
|
// 处理标记
|
||||||
|
Dictionary<Guid,Guid> dicomKeys=new Dictionary<Guid, Guid> ();
|
||||||
|
|
||||||
|
foreach (var item in questionMarkList)
|
||||||
|
{
|
||||||
|
item.Id = NewId.NextGuid();
|
||||||
|
item.VisitTaskId = taskinfo.Id;
|
||||||
|
item.FristAddTaskId = taskinfo.Id;
|
||||||
|
if (item.MarkId != null)
|
||||||
|
{
|
||||||
|
if (dicomKeys.ContainsKey(item.MarkId.Value))
|
||||||
|
{
|
||||||
|
item.MarkId = dicomKeys[item.MarkId.Value];
|
||||||
|
item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), dicomKeys[item.MarkId.Value].ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newguid = NewId.NextGuid();
|
||||||
|
|
||||||
|
item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), newguid.ToString());
|
||||||
|
dicomKeys.Add(item.MarkId.Value, newguid);
|
||||||
|
item.MarkId = dicomKeys[item.MarkId.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await _readingTaskQuestionMarkRepository.AddRangeAsync(questionMarkList);
|
||||||
|
|
||||||
|
|
||||||
|
// 处理非Dicom标记
|
||||||
|
Dictionary<Guid, Guid> noneKeys = new Dictionary<Guid, Guid>();
|
||||||
|
foreach (var item in noneDicomMarkList)
|
||||||
|
{
|
||||||
|
var newid= NewId.NextGuid();
|
||||||
|
|
||||||
|
item.VisitTaskId = taskinfo.Id;
|
||||||
|
if (item.MarkId != null)
|
||||||
|
{
|
||||||
|
if (noneKeys.ContainsKey(item.MarkId.Value))
|
||||||
|
{
|
||||||
|
item.MarkId = noneKeys[item.MarkId.Value];
|
||||||
|
item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), noneKeys[item.MarkId.Value].ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newguid = NewId.NextGuid();
|
||||||
|
|
||||||
|
item.MeasureData = item.MeasureData.Replace(historyTaskId.ToString(), taskinfo.Id.ToString()).Replace(item.MarkId.Value.ToString(), newguid.ToString());
|
||||||
|
noneKeys.Add(item.MarkId.Value, newguid);
|
||||||
|
item.MarkId = noneKeys[item.MarkId.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 处理非DICOM绑定
|
||||||
|
// 处理非DICOM绑定
|
||||||
|
foreach (var binding in noneDicomMarkBindingList.Where(z => z.MarkId == item.MarkId))
|
||||||
|
{
|
||||||
|
binding.Id = NewId.NextGuid();
|
||||||
|
binding.VisitTaskId = taskinfo.Id;
|
||||||
|
if (binding.MarkId != null)
|
||||||
|
{
|
||||||
|
binding.NoneDicomMarkId = newid;
|
||||||
|
|
||||||
|
if (noneKeys.ContainsKey(binding.MarkId.Value))
|
||||||
|
{
|
||||||
|
binding.MarkId = noneKeys[binding.MarkId.Value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
item.Id = NewId.NextGuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
await _readingNoneDicomMarkRepository.AddRangeAsync(noneDicomMarkList);
|
||||||
|
|
||||||
|
|
||||||
|
await _readingNoneDicomMarkBindingRepository.AddRangeAsync(noneDicomMarkBindingList);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从上传文件中获取Datatable
|
/// 从上传文件中获取Datatable
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,16 @@ namespace IRaCIS.Core.Application.Service
|
||||||
List<QuestionMark?> needChangeType
|
List<QuestionMark?> needChangeType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 复制历史答案到当前任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="taskinfo"></param>
|
||||||
|
/// <param name="tableRowList"></param>
|
||||||
|
/// <param name="tableAnswerList"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
Task CopyHistoryAnswer(VisitTask taskinfo, List<ReadingTableAnswerRowInfo> tableRowList, List<ReadingTableQuestionAnswer> tableAnswerList)
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取ReadingCalculateDto
|
/// 获取ReadingCalculateDto
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue