From ee0526986fba034d4812e43a804020073d1b3558 Mon Sep 17 00:00:00 2001
From: he <10978375@qq.com>
Date: Fri, 17 Jun 2022 15:52:56 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=89=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 8 +++
.../Reading/Dto/ReadingImageTaskViewModel.cs | 20 +++++-
.../Reading/ReadingImageTaskService.cs | 63 +++++++++++++++++--
IRaCIS.Core.Domain/Allocation/VisitTask.cs | 10 +++
4 files changed, 95 insertions(+), 6 deletions(-)
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index f78fa400b..9d2ff512d 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -4241,6 +4241,14 @@
IR影像阅片
+
+
+ 获取下一个阅片任务
+
+
+
+
+
获取阅片非Dicom文件
diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
index b83f84bed..ca734ccae 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs
@@ -1,4 +1,5 @@
-using System;
+using IRaCIS.Core.Domain.Share;
+using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
@@ -15,10 +16,25 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public string FileName { get; set; }
}
+ public class GetReadingTaskDto
+ {
+ public Guid VisistId { get; set; }
+
+ public Guid SubjectId { get; set; }
+
+ public ReadingCategory ReadingCategory { get; set; }
+
+ public decimal VisitNum{ get; set; }
+
+}
+
public class GetReadingImgInDto
{
- public Guid VisitTaskId { get; set; }
+ public Guid? SubjectId { get; set; }
+
+ [NotDefault]
+ public Guid TrialId { get; set; }
}
public class GetConfirmCriterionInDto
diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
index 0eedbec77..9a033f067 100644
--- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
+++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs
@@ -25,6 +25,7 @@ namespace IRaCIS.Application.Services
private readonly IMapper mapper;
private readonly IRepository _noneDicomStudyRepository;
private readonly IRepository _visitTaskRepository;
+ private readonly IRepository _subjectVisitRepository;
private readonly IRepository _readingTaskQuestionAnswerRepository;
private readonly IRepository _readingQuestionCriterionTrialRepository;
private readonly IRepository _readingQuestionTrialRepository;
@@ -33,6 +34,7 @@ namespace IRaCIS.Application.Services
IMapper mapper,
IRepository noneDicomStudyRepository,
IRepository visitTaskRepository,
+ IRepository subjectVisitRepository,
IRepository readingTaskQuestionAnswerRepository,
IRepository readingQuestionCriterionTrialRepository,
IRepository readingQuestionTrialRepository
@@ -41,9 +43,54 @@ namespace IRaCIS.Application.Services
this.mapper = mapper;
this._noneDicomStudyRepository = noneDicomStudyRepository;
this._visitTaskRepository = visitTaskRepository;
+ this._subjectVisitRepository = subjectVisitRepository;
this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository;
this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository;
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
+ }
+
+ ///
+ /// 获取下一个阅片任务
+ ///
+ ///
+ ///
+ ///
+ private async Task GetNextTaskId(Guid? subjectId,Guid trialId)
+ {
+ GetReadingTaskDto? task = new GetReadingTaskDto();
+ if (subjectId != null)
+ {
+ task = await _visitTaskRepository.Where(x => x.TrialId == trialId && x.ReadingTaskState != ReadingTaskState.HaveSigned && x.SubjectId == subjectId.Value).Select(x => new GetReadingTaskDto()
+ {
+
+ ReadingCategory = x.ReadingCategory,
+ VisistId = x.ReadingCategory == ReadingCategory.Visit ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId,
+ VisitNum = x.ReadingCategory == ReadingCategory.Visit ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum
+ }).OrderBy(x => x.VisitNum).ThenBy(x => x.ReadingCategory).FirstOrDefaultAsync();
+ task.SubjectId = subjectId.Value;
+
+
+ }
+ else
+ {
+ task = await _visitTaskRepository.Where(x => x.TrialId == trialId && x.ReadingTaskState != ReadingTaskState.HaveSigned).Select(x => new GetReadingTaskDto()
+ {
+
+ ReadingCategory = x.ReadingCategory,
+ VisistId = x.ReadingCategory == ReadingCategory.Visit ? x.SourceSubjectVisitId.Value : x.ReadModule.SubjectVisitId,
+ VisitNum = x.ReadingCategory == ReadingCategory.Visit ? x.SubjectVisit.VisitNum : x.ReadModule.VisitNum
+ }).FirstOrDefaultAsync();
+
+ task.SubjectId = await _subjectVisitRepository.Where(x => x.Id == task.VisistId).Select(x => x.SubjectId).FirstOrDefaultAsync();
+ }
+
+ return task;
+
+
+
+
+
+
}
///
@@ -54,12 +101,20 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task> GetReadingImageFile(GetReadingImgInDto inDto)
{
- Guid? subjectVisitId = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Select(x => x.SourceSubjectVisitId).FirstOrDefaultAsync();
- if (subjectVisitId == null)
+ var task=await GetNextTaskId(inDto.SubjectId, inDto.TrialId);
+ List visitIds = new List();
+ if (task.ReadingCategory == ReadingCategory.Visit)
{
- throw new QueryBusinessObjectNotExistException($"数据异常,当前任务没有访视Id");
+ visitIds.Add(task.VisistId);
}
- List imgList = await _noneDicomStudyRepository.Where(x => x.SubjectVisitId == subjectVisitId)
+ else
+ {
+ // 阅片期取前面所有的图像
+ visitIds.AddRange(await _subjectVisitRepository.Where(x => x.VisitNum <= task.VisitNum && x.SubjectId == task.SubjectId).Select(x => x.Id).ToListAsync());
+ }
+
+
+ List imgList = await _noneDicomStudyRepository.Where(x => visitIds.Contains(x.SubjectVisitId))
.SelectMany(x => x.NoneDicomFileList).Select(x => new GetReadingImgOutDto()
{
FileName = x.FileName,
diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
index a45cb33a4..95f0cbf13 100644
--- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs
+++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
@@ -60,9 +60,15 @@ namespace IRaCIS.Core.Domain.Models
//任务来源访视Id 方便回更访视读片状态
public Guid? SourceSubjectVisitId { get; set; }
+ [ForeignKey("SourceSubjectVisitId")]
+ public SubjectVisit SubjectVisit { get; set; }
+
public Guid? SouceReadModuleId { get; set; }
+ [ForeignKey("SouceReadModuleId")]
+ public ReadModule ReadModule { get; set; }
+
///
@@ -172,6 +178,10 @@ namespace IRaCIS.Core.Domain.Models
public SubjectUser SujectArm { get; set; }
+
+
+
+
//建议完成时间
//public int SuggesteDays { get; set; }
}