修改一版
parent
d393d1a84a
commit
3d92ccf83a
|
@ -213,7 +213,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置阅片是否生效
|
/// 设置阅片是否生效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IsTakeEffect { get; set; }
|
public ReadingPeriodStatus IsTakeEffect { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ReadingPeriodSetQuery
|
public class ReadingPeriodSetQuery
|
||||||
|
|
|
@ -23,17 +23,20 @@ namespace IRaCIS.Application.Services
|
||||||
public IRepository<SubjectVisit> _subjectVisitRepository;
|
public IRepository<SubjectVisit> _subjectVisitRepository;
|
||||||
private readonly IRepository<ReadingPeriodSet> _readingPeriodSetRepository;
|
private readonly IRepository<ReadingPeriodSet> _readingPeriodSetRepository;
|
||||||
private readonly IRepository<ReadModule> _readModuleRepository;
|
private readonly IRepository<ReadModule> _readModuleRepository;
|
||||||
|
private readonly IRepository<ReadingPeriodPlan> _readingPeriodPlanRepository;
|
||||||
private readonly IRepository<Site> _siteSetRepository;
|
private readonly IRepository<Site> _siteSetRepository;
|
||||||
|
|
||||||
public ReadingPeriodSetService(IRepository<SubjectVisit> subjectVisitRepository,
|
public ReadingPeriodSetService(IRepository<SubjectVisit> subjectVisitRepository,
|
||||||
IRepository<ReadingPeriodSet> ReadingPeriodSetRepository,
|
IRepository<ReadingPeriodSet> ReadingPeriodSetRepository,
|
||||||
IRepository<ReadModule> readModuleRepository,
|
IRepository<ReadModule> readModuleRepository,
|
||||||
|
IRepository<ReadingPeriodPlan> readingPeriodPlanRepository,
|
||||||
IRepository<Site> SiteSetRepository
|
IRepository<Site> SiteSetRepository
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_subjectVisitRepository = subjectVisitRepository;
|
_subjectVisitRepository = subjectVisitRepository;
|
||||||
_readingPeriodSetRepository = ReadingPeriodSetRepository;
|
_readingPeriodSetRepository = ReadingPeriodSetRepository;
|
||||||
this._readModuleRepository = readModuleRepository;
|
this._readModuleRepository = readModuleRepository;
|
||||||
|
this._readingPeriodPlanRepository = readingPeriodPlanRepository;
|
||||||
_siteSetRepository = SiteSetRepository;
|
_siteSetRepository = SiteSetRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,12 +94,34 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
visitquery = visitquery.WhereIf(readset.ExpirationDate != null, x => x.LatestScanDate <= readset.ExpirationDate.Value)
|
visitquery = visitquery.WhereIf(readset.ExpirationDate != null, x => x.LatestScanDate <= readset.ExpirationDate.Value)
|
||||||
.WhereIf(readset.ExpirationVisitNum != null, x => x.VisitNum <= readset.ExpirationVisitNum);
|
.WhereIf(readset.ExpirationVisitNum != null, x => x.VisitNum <= readset.ExpirationVisitNum);
|
||||||
var visits = (await visitquery.Include(x=>x.Subject).Include(x=>x.TrialSite).GroupBy(x => x.SubjectId).Select(x => new
|
var subjectVisits = await visitquery.Include(x => x.Subject).Include(x => x.TrialSite).GroupBy(x => x.SubjectId).Select(x => new
|
||||||
{
|
{
|
||||||
SubjectId = x.Key,
|
SubjectId = x.Key,
|
||||||
visit = x.OrderByDescending(x => x.VisitNum).FirstOrDefault()
|
Visit = x.ToList()
|
||||||
}).ToListAsync()).Select(x => x.visit).ToList();
|
}).ToListAsync();
|
||||||
|
|
||||||
|
List<SubjectVisit> visits = new List<SubjectVisit>();
|
||||||
|
subjectVisits.ForEach(x =>
|
||||||
|
{
|
||||||
|
var finalVisit = x.Visit.Where(x => x.IsFinalVisit).FirstOrDefault();
|
||||||
|
if (finalVisit != null)
|
||||||
|
{
|
||||||
|
var visit = x.Visit.Where(x => x.VisitNum < finalVisit.VisitNum).OrderByDescending(x=>x.VisitNum).FirstOrDefault();
|
||||||
|
if(visit!=null)
|
||||||
|
{
|
||||||
|
visits.Add(visit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var visit = x.Visit.OrderByDescending(x => x.VisitNum).FirstOrDefault();
|
||||||
|
if (visit != null)
|
||||||
|
{
|
||||||
|
visits.Add(visit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
return visits.Where(x => _readModuleRepository.Where(y => y.ReadingSetType == readset.ReadingSetType && x.Id == y.SubjectVisitId).Count() == 0)
|
return visits.Where(x => _readModuleRepository.Where(y => y.ReadingSetType == readset.ReadingSetType && x.Id == y.SubjectVisitId).Count() == 0)
|
||||||
.Select(x => new PreviewTheReadingListOutDto
|
.Select(x => new PreviewTheReadingListOutDto
|
||||||
|
@ -121,35 +146,72 @@ namespace IRaCIS.Application.Services
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<IResponseOutput> ReadingToGenerate(ReadingToGenerateInDto inDto)
|
public async Task<IResponseOutput> ReadingToGenerate(ReadingToGenerateInDto inDto)
|
||||||
{
|
{
|
||||||
var readset = (await _readingPeriodSetRepository.Where(x => x.Id == inDto.ReadingPeriodSetId).Include(x => x.ReadingPeriodSites).FirstOrDefaultAsync()).IfNullThrowConvertException();
|
//var readset = (await _readingPeriodSetRepository.Where(x => x.Id == inDto.ReadingPeriodSetId).Include(x => x.ReadingPeriodSites).FirstOrDefaultAsync()).IfNullThrowConvertException();
|
||||||
var visits = await _subjectVisitRepository.Where(x => inDto.SubjectVisitIds.Contains(x.Id)).ToListAsync();
|
//var visits = await _subjectVisitRepository.Where(x => inDto.SubjectVisitIds.Contains(x.Id)).ToListAsync();
|
||||||
|
|
||||||
List<ReadModule> readModules = new List<ReadModule>();
|
//List<ReadModule> readModules = new List<ReadModule>();
|
||||||
|
|
||||||
foreach (var item in visits)
|
//foreach (var item in visits)
|
||||||
|
//{
|
||||||
|
// readModules.Add(new ReadModule()
|
||||||
|
// {
|
||||||
|
// Id = NewId.NextGuid(),
|
||||||
|
// SubjectId = item.SubjectId,
|
||||||
|
// ModuleType = readset.ReadingSetType == ReadingSetType.ImageReading ? ModuleTypeEnum.Read : ModuleTypeEnum.Oncology,
|
||||||
|
// IsUrgent = item.IsUrgent,
|
||||||
|
// ModuleName = readset.ReadingPeriodName,
|
||||||
|
// SubjectVisitId = item.Id,
|
||||||
|
// ReadingSetType = readset.ReadingSetType,
|
||||||
|
// Status = ReadingCommon.GetVisitSubmitStateEnum(item),
|
||||||
|
// });
|
||||||
|
//};
|
||||||
|
|
||||||
|
//await _readModuleRepository.AddRangeAsync(readModules);
|
||||||
|
|
||||||
|
|
||||||
|
//var res = await _subjectVisitRepository.SaveChangesAsync();
|
||||||
|
|
||||||
|
List<ReadingPeriodPlan> plans = new List<ReadingPeriodPlan>();
|
||||||
|
inDto.SubjectVisitIds.ForEach(x =>
|
||||||
{
|
{
|
||||||
readModules.Add(new ReadModule()
|
plans.Add(new ReadingPeriodPlan()
|
||||||
{
|
{
|
||||||
Id = NewId.NextGuid(),
|
SubjectVisitId = x,
|
||||||
SubjectId = item.SubjectId,
|
ReadingPeriodSetId = inDto.ReadingPeriodSetId
|
||||||
ModuleType = readset.ReadingSetType == ReadingSetType.ImageReading ? ModuleTypeEnum.Read : ModuleTypeEnum.Oncology,
|
});
|
||||||
IsUrgent = item.IsUrgent,
|
|
||||||
ModuleName = readset.ReadingPeriodName,
|
|
||||||
SubjectVisitId = item.Id,
|
|
||||||
ReadingSetType = readset.ReadingSetType,
|
|
||||||
Status = ReadingCommon.GetVisitSubmitStateEnum(item),
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
await _readModuleRepository.AddRangeAsync(readModules);
|
|
||||||
|
|
||||||
|
|
||||||
var res = await _subjectVisitRepository.SaveChangesAsync();
|
|
||||||
|
|
||||||
|
|
||||||
|
await _readingPeriodPlanRepository.AddRangeAsync(plans);
|
||||||
|
var res = await _readingPeriodPlanRepository.SaveChangesAsync();
|
||||||
return ResponseOutput.Result(res);
|
return ResponseOutput.Result(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取选中的计划
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<PreviewTheReadingListOutDto>> GetPreviewTheReadingPlanList(PreviewTheReadingListInDto inDto)
|
||||||
|
{
|
||||||
|
var plans =await _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == inDto.ReadingPeriodSetId).Include(x => x.SubjectVisit).Include(x => x.SubjectVisit.TrialSite).Include(x => x.SubjectVisit.Subject)
|
||||||
|
.Include(x => x.ReadingPeriodSet).ToListAsync();
|
||||||
|
|
||||||
|
return plans.Select(x => new PreviewTheReadingListOutDto
|
||||||
|
{
|
||||||
|
ExpirationDate = x.ReadingPeriodSet.ExpirationDate,
|
||||||
|
SubjectVisitId = x.Id,
|
||||||
|
TrialSiteCode = x.SubjectVisit.TrialSite.TrialSiteCode,
|
||||||
|
LatestScanDate =x.SubjectVisit.LatestScanDate,
|
||||||
|
ReadingPeriodName = x.ReadingPeriodSet.ReadingPeriodName,
|
||||||
|
ReadingPeriodSetId = x.ReadingPeriodSet.Id,
|
||||||
|
SubjectCode = x.SubjectVisit.Subject.Code,
|
||||||
|
SubjectId = x.SubjectVisit.SubjectId,
|
||||||
|
SubjectVisitName = x.SubjectVisit.VisitName,
|
||||||
|
//Remark= readset.Remark
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分页获取
|
/// 分页获取
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -164,10 +226,11 @@ namespace IRaCIS.Application.Services
|
||||||
.ProjectTo<ReadingPeriodSetView>(_mapper.ConfigurationProvider);
|
.ProjectTo<ReadingPeriodSetView>(_mapper.ConfigurationProvider);
|
||||||
var pageList= await readquery.ToPagedListAsync(query.PageIndex, query.PageSize, query.SortField == null ? "CreateTime" : query.SortField,
|
var pageList= await readquery.ToPagedListAsync(query.PageIndex, query.PageSize, query.SortField == null ? "CreateTime" : query.SortField,
|
||||||
query.SortAsc);
|
query.SortAsc);
|
||||||
|
|
||||||
return pageList;
|
return pageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取单条
|
/// 获取单条
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -177,7 +240,6 @@ namespace IRaCIS.Application.Services
|
||||||
public async Task<ReadingPeriodSetView> GetReadingPeriodSet(Guid id)
|
public async Task<ReadingPeriodSetView> GetReadingPeriodSet(Guid id)
|
||||||
{
|
{
|
||||||
var data = await _readingPeriodSetRepository.AsQueryable().Include(x => x.ReadingPeriodSites).Where(x => x.Id == id).ProjectTo<ReadingPeriodSetView>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
var data = await _readingPeriodSetRepository.AsQueryable().Include(x => x.ReadingPeriodSites).Where(x => x.Id == id).ProjectTo<ReadingPeriodSetView>(_mapper.ConfigurationProvider).FirstOrDefaultAsync();
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -191,11 +253,40 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
public async Task<IResponseOutput> SetReadingPeriodSetEffect(SetReadingPeriodSetEffect indto)
|
public async Task<IResponseOutput> SetReadingPeriodSetEffect(SetReadingPeriodSetEffect indto)
|
||||||
{
|
{
|
||||||
|
if (indto.IsTakeEffect == ReadingPeriodStatus.TakeEffect)
|
||||||
|
{
|
||||||
|
var plans = _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Include(x=>x.SubjectVisit)
|
||||||
|
.Include(x => x.ReadingPeriodSet).ToList();
|
||||||
|
|
||||||
|
List<ReadModule> readModules = new List<ReadModule>();
|
||||||
|
foreach (var item in plans)
|
||||||
|
{
|
||||||
|
readModules.Add(new ReadModule()
|
||||||
|
{
|
||||||
|
Id = NewId.NextGuid(),
|
||||||
|
SubjectId = item.SubjectVisit.SubjectId,
|
||||||
|
ModuleType = item.ReadingPeriodSet.ReadingSetType == ReadingSetType.ImageReading ? ModuleTypeEnum.Read : ModuleTypeEnum.Oncology,
|
||||||
|
IsUrgent = item.SubjectVisit.IsUrgent,
|
||||||
|
ModuleName = item.ReadingPeriodSet.ReadingPeriodName,
|
||||||
|
SubjectVisitId = item.Id,
|
||||||
|
ReadingSetType = item.ReadingPeriodSet.ReadingSetType,
|
||||||
|
ReadingPeriodSetId= item.ReadingPeriodSet.Id,
|
||||||
|
Status = ReadingCommon.GetVisitSubmitStateEnum(item.SubjectVisit),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
await _readModuleRepository.AddRangeAsync(readModules);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
await _readModuleRepository.DeleteFromQueryAsync(x => x.ReadingPeriodSetId == indto.Id);
|
||||||
|
}
|
||||||
|
|
||||||
var readquery =await _readingPeriodSetRepository.UpdatePartialFromQueryAsync(indto.Id, x => new ReadingPeriodSet() {
|
var readquery =await _readingPeriodSetRepository.UpdatePartialFromQueryAsync(indto.Id, x => new ReadingPeriodSet() {
|
||||||
IsTakeEffect = indto.IsTakeEffect
|
IsTakeEffect = indto.IsTakeEffect
|
||||||
},true);
|
});
|
||||||
|
|
||||||
return ResponseOutput.Result(true);
|
var res=await _readingPeriodSetRepository.SaveChangesAsync();
|
||||||
|
return ResponseOutput.Result(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,6 +299,7 @@ namespace IRaCIS.Application.Services
|
||||||
[HttpDelete("{readingPeriodSetId:guid}")]
|
[HttpDelete("{readingPeriodSetId:guid}")]
|
||||||
public async Task<IResponseOutput> DeleteReadingPeriodSet(Guid readingPeriodSetId)
|
public async Task<IResponseOutput> DeleteReadingPeriodSet(Guid readingPeriodSetId)
|
||||||
{
|
{
|
||||||
|
|
||||||
var success = await _repository.BatchDeleteAsync<ReadingPeriodSet>(t => t.Id == readingPeriodSetId);
|
var success = await _repository.BatchDeleteAsync<ReadingPeriodSet>(t => t.Id == readingPeriodSetId);
|
||||||
return ResponseOutput.Result(success);
|
return ResponseOutput.Result(success);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace IRaCIS.Core.Domain.Share.Reading
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 状态
|
/// 状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using IRaCIS.Core.Domain.Share.Reading;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Domain.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
/// 阅片计划
|
||||||
|
///</summary>
|
||||||
|
[Table("ReadingPeriodPlan")]
|
||||||
|
public class ReadingPeriodPlan : Entity, IAuditAdd
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 阅片期配置ID
|
||||||
|
/// </summary>
|
||||||
|
public Guid ReadingPeriodSetId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 访视
|
||||||
|
/// </summary>
|
||||||
|
public Guid SubjectVisitId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 访视
|
||||||
|
/// </summary>
|
||||||
|
[ForeignKey("SubjectVisitId")]
|
||||||
|
public SubjectVisit SubjectVisit { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 阅片期配置
|
||||||
|
/// </summary>
|
||||||
|
[ForeignKey("ReadingPeriodSetId")]
|
||||||
|
public ReadingPeriodSet ReadingPeriodSet { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
public Guid CreateUserId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -55,7 +55,7 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否生效
|
/// 是否生效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int? IsTakeEffect { get; set; }
|
public ReadingPeriodStatus IsTakeEffect { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建时间
|
/// 创建时间
|
||||||
|
@ -75,4 +75,6 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public List<ReadingPeriodSite> ReadingPeriodSites { get; set; } = new List<ReadingPeriodSite>();
|
public List<ReadingPeriodSite> ReadingPeriodSites { get; set; } = new List<ReadingPeriodSite>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,9 @@ namespace IRaCIS.Core.Infra.EFCore
|
||||||
#region Reading
|
#region Reading
|
||||||
public virtual DbSet<ReadingPeriodSet> ReadingPeriodSet { get; set; }
|
public virtual DbSet<ReadingPeriodSet> ReadingPeriodSet { get; set; }
|
||||||
|
|
||||||
|
public virtual DbSet<ReadingPeriodPlan> ReadingPeriodPlan { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public virtual DbSet<ReadModule> ReadModule { get; set; }
|
public virtual DbSet<ReadModule> ReadModule { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<ClinicalData> ClinicalData { get; set; }
|
public virtual DbSet<ClinicalData> ClinicalData { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue