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 passing
Details
continuous-integration/drone/push Build is passing
Details
commit
eccb5dc562
|
@ -10,6 +10,7 @@ namespace IRaCIS.Core.Application.Helper
|
|||
|
||||
public static class CacheKeys
|
||||
{
|
||||
//项目缓存
|
||||
public static string Trial(string trialIdStr) => $"TrialId:{trialIdStr}";
|
||||
|
||||
//检查编号递增锁
|
||||
|
@ -33,8 +34,6 @@ namespace IRaCIS.Core.Application.Helper
|
|||
//超时没请求接口自动退出
|
||||
public static string UserAutoLoginOut(Guid userId) => $"UserAutoLoginOut:{userId}";
|
||||
|
||||
// 你可以为其他实体和模块定义更多的键
|
||||
|
||||
/// <summary>
|
||||
/// 跳过阅片
|
||||
/// </summary>
|
||||
|
|
|
@ -109,17 +109,13 @@ namespace IRaCIS.Core.Application.Helper
|
|||
public string AccessKeyId { get; set; }
|
||||
public string AccessKeySecret { get; set; }
|
||||
|
||||
|
||||
public string EndPoint { get; set; }
|
||||
public string BucketName { get; set; }
|
||||
|
||||
|
||||
public string Region { get; set; }
|
||||
|
||||
public string ViewEndpoint { get; set; }
|
||||
|
||||
|
||||
|
||||
public string SecurityToken { get; set; }
|
||||
public DateTime Expiration { get; set; }
|
||||
|
||||
|
|
|
@ -602,9 +602,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
[JsonIgnore]
|
||||
public List<SubjectUserView> DoctorUserList { get; set; }
|
||||
|
||||
public List<SubjectUserView> PreviousDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId != null).ToList();
|
||||
public List<SubjectUserView> PreviousDoctorUserList => DoctorUserList.Where(t => t.ReplacedSubjectUserId != null).ToList();
|
||||
|
||||
public List<SubjectUserView> NowDoctorUserList => DoctorUserList.Where(t => t.OrignalSubjectUserId == null).ToList();
|
||||
public List<SubjectUserView> NowDoctorUserList => DoctorUserList.Where(t => t.ReplacedSubjectUserId == null).ToList();
|
||||
|
||||
|
||||
|
||||
|
@ -622,7 +622,7 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public bool IsConfirmed { get; set; }
|
||||
|
||||
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
||||
public Guid? OrignalSubjectUserId { get; set; }
|
||||
public Guid? ReplacedSubjectUserId { get; set; }
|
||||
|
||||
public UserSimpleInfo DoctorUser { get; set; }
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
foreach (var subjectGroup in needGenerateVisit.GroupBy(t => t.SubjectId).Select(g => new { SubjectId = g.Key, SubjectVisitList = g.ToList() }))
|
||||
{
|
||||
var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectGroup.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync();
|
||||
var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectGroup.SubjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync();
|
||||
|
||||
|
||||
|
||||
|
@ -632,7 +632,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
{
|
||||
|
||||
var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.OrignalSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync();
|
||||
var assignConfigList = await _subjectUserRepository.Where(t => t.TrialId == trialId && t.TrialReadingCriterionId == trialReadingCriterionConfig.TrialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed).Select(u => new { u.DoctorUserId, u.ArmEnum }).ToListAsync();
|
||||
|
||||
var isNeedClinicalDataSign = IsNeedClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList);
|
||||
var isClinicalDataSign = IsClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList, subjectVisit.Id, trialId);
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
{
|
||||
foreach (var doctorArm in command.DoctorArmList)
|
||||
{
|
||||
if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.OrignalSubjectUserId == null))
|
||||
if (!await _subjectUserRepository.Where(t => t.TrialReadingCriterionId == command.TrialReadingCriterionId).AnyAsync(t => t.SubjectId == subjectId && t.DoctorUserId == doctorArm.DoctorUserId && t.ArmEnum == doctorArm.ArmEnum && t.IsConfirmed && t.ReplacedSubjectUserId == null))
|
||||
{
|
||||
await _subjectUserRepository.AddAsync(new SubjectUser() { TrialId = command.TrialId, TrialReadingCriterionId = command.TrialReadingCriterionId, ArmEnum = doctorArm.ArmEnum, DoctorUserId = doctorArm.DoctorUserId, SubjectId = subjectId, AssignTime = DateTime.Now });
|
||||
|
||||
|
@ -246,7 +246,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
/// <returns></returns>
|
||||
public async Task<(List<SubjectUserDTO>, object)> GetSubjectAssignedDoctorList(Guid subjectId, Guid trialReadingCriterionId)
|
||||
{
|
||||
var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo<SubjectUserDTO>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
var list = await _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null && t.IsConfirmed && t.TrialReadingCriterionId == trialReadingCriterionId).ProjectTo<SubjectUserDTO>(_mapper.ConfigurationProvider).ToListAsync();
|
||||
|
||||
var criterionConfig = (await _trialReadingCriterionRepository.Where(x => x.Id == trialReadingCriterionId).Select(x => new { x.ReadingTool, x.IsReadingTaskViewInOrder, x.ReadingType, x.IsGlobalReading, x.IsOncologyReading, x.IsArbitrationReading }).FirstOrDefaultAsync()).IfNullThrowException();
|
||||
|
||||
|
@ -479,13 +479,13 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
var armEnum = assginSubjectDoctorCommand.DoctorUserIdArmList.Where(t => t.DoctorUserId == doctorUserId).First().ArmEnum;
|
||||
|
||||
|
||||
if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.OrignalSubjectUserId == null))
|
||||
if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum != armEnum && t.ReplacedSubjectUserId == null))
|
||||
{
|
||||
//---有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生
|
||||
throw new BusinessValidationFailedException(_localizer["VisitTask_InconsistentSubjectStatus"]);
|
||||
}
|
||||
|
||||
if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.OrignalSubjectUserId == null))
|
||||
if (await _subjectUserRepository.AnyAsync(t => t.TrialId == trialId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.ArmEnum == armEnum && t.ReplacedSubjectUserId == null))
|
||||
{
|
||||
//---有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期
|
||||
throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]);
|
||||
|
@ -568,11 +568,11 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
//将关系确认
|
||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
||||
{
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.OrignalSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null, u => new SubjectUser() { IsConfirmed = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.OrignalSubjectUserId == null
|
||||
await _subjectUserRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialId && t.IsConfirmed == false && t.ReplacedSubjectUserId == null
|
||||
&& subjectIdList.Contains(t.SubjectId), u => new SubjectUser() { IsConfirmed = true });
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
|||
|
||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
||||
{
|
||||
subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.OrignalSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList();
|
||||
subjectDoctorIdArmList = _subjectUserRepository.Where(t => t.SubjectId == subjectId && t.ReplacedSubjectUserId == null).Select(t => new DoctorArm() { DoctorUserId = t.DoctorUserId, ArmEnum = t.ArmEnum }).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -527,6 +527,8 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
[NotDefault]
|
||||
public string SubjectCode { get; set; }
|
||||
|
||||
public Guid? VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -554,6 +556,6 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
{
|
||||
public Guid SubjectVisitId { get; set; }
|
||||
|
||||
public Guid VisitTaskId { get; set; }
|
||||
public Guid TaskId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -606,7 +606,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
|
||||
var query = from u in _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
|
||||
&& t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect)
|
||||
join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter,t=> ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|"))
|
||||
join ns in _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId).WhereIf(info.IsImageFilter, t => ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|"))
|
||||
on u.SourceSubjectVisitId equals ns.SubjectVisitId
|
||||
|
||||
select new TaskNoneDicomStudyDTO()
|
||||
|
@ -738,9 +738,21 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
[HttpPost]
|
||||
public async Task<List<SubjectCRCImageUploadedStudyDto>> GetSubjectImageDownloadSelectList(IRReadingDownloadQuery inQuery)
|
||||
{
|
||||
var doctorUserId = _userInfo.Id;
|
||||
|
||||
var isAnalysisCreate = false;
|
||||
|
||||
//医学审核查看下载按钮,这个时候需要知道医生
|
||||
if (inQuery.VisitTaskId != null && inQuery.VisitTaskId != Guid.Empty)
|
||||
{
|
||||
var info = await _visitTaskRepository.Where(t => t.Id == inQuery.VisitTaskId).Select(t => new { t.DoctorUserId, t.IsAnalysisCreate }).FirstNotNullAsync();
|
||||
|
||||
doctorUserId = (Guid)info.DoctorUserId!;
|
||||
isAnalysisCreate = info.IsAnalysisCreate;
|
||||
}
|
||||
|
||||
var query = _visitTaskRepository.Where(t => t.SubjectId == inQuery.SubjectId && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId
|
||||
&& t.SourceSubjectVisitId != null && t.DoctorUserId == _userInfo.Id && t.TaskState == TaskState.Effect)
|
||||
&& t.SourceSubjectVisitId != null && t.DoctorUserId == doctorUserId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == isAnalysisCreate)
|
||||
.ProjectTo<SubjectCRCImageUploadedDto>(_mapper.ConfigurationProvider);
|
||||
|
||||
|
||||
|
@ -816,10 +828,14 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
|||
var isQueryDicom = inQuery.DicomStudyIdList.Count > 0;
|
||||
var isQueryNoneDicom = inQuery.NoneDicomStudyIdList.Count > 0;
|
||||
|
||||
var taskIdList = inQuery.SubjectVisitTaskList.Select(t => t.TaskId).ToList();
|
||||
|
||||
var subjectVisitIdList = inQuery.SubjectVisitTaskList.Select(t => t.SubjectVisitId).ToList();
|
||||
|
||||
var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id)))
|
||||
join visitTask in _visitTaskRepository.Where(t => t.TaskState == TaskState.Effect && t.DoctorUserId == _userInfo.Id && t.TrialReadingCriterionId == inQuery.TrialReadingCriterionId)
|
||||
//一致性分析,导致查询出来两条数据
|
||||
join visitTask in _visitTaskRepository.Where(t => taskIdList.Contains(t.Id))
|
||||
|
||||
on sv.Id equals visitTask.SourceSubjectVisitId
|
||||
select new
|
||||
{
|
||||
|
|
|
@ -136,7 +136,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
.ForMember(d => d.FeedBackUserName, c => c.MapFrom(t => t.CreateUser.UserName))
|
||||
.ForMember(d => d.FeedBackFullName, c => c.MapFrom(t => t.CreateUser.FullName))
|
||||
.ForMember(d => d.UserTypeEnum, c => c.MapFrom(t => t.CreateUser.UserTypeEnum));
|
||||
CreateMap<UserFeedBack, UserFeedBackAddOrEdit>().ReverseMap();
|
||||
|
||||
CreateMap<UserFeedBackAddOrEdit, UserFeedBack>().ReverseMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ using Panda.DynamicWebApi.Attributes;
|
|||
using IRaCIS.Core.Application.Contracts;
|
||||
using MassTransit;
|
||||
using IRaCIS.Core.Application.Filter;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
@ -66,7 +67,7 @@ namespace IRaCIS.Application.Services
|
|||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput<List<NoneDicomStudyView>> > GetReadingImageFile(GetReadingImgInDto inDto)
|
||||
public async Task<IResponseOutput<List<NoneDicomStudyView>>> GetReadingImageFile(GetReadingImgInDto inDto)
|
||||
{
|
||||
var task = await GetNextTask(new GetNextTaskInDto()
|
||||
{
|
||||
|
@ -84,10 +85,26 @@ namespace IRaCIS.Application.Services
|
|||
// 阅片期取前面所有的图像
|
||||
visitIds.AddRange(await _subjectVisitRepository.Where(x => x.VisitNum <= task.VisitNum && x.SubjectId == task.SubjectId).Select(x => x.Id).ToListAsync());
|
||||
}
|
||||
List<NoneDicomStudyView> result = await _noneDicomStudyRepository.Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t=>!t.FileType.Contains(StaticData.FileType.Zip)))
|
||||
.ProjectTo<NoneDicomStudyView>(_mapper.ConfigurationProvider, new { isFilterZip = true }).ToListAsync();
|
||||
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).FirstNotNullAsync();
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisistTaskId).Select(t => new { t.BlindSubjectCode, t.TrialReadingCriterionId, t.TrialReadingCriterion.IsImageFilter, t.TrialReadingCriterion.CriterionModalitys }).FirstNotNullAsync();
|
||||
|
||||
|
||||
IQueryable<NoneDicomStudyView> noneDicomStudyQueryable = default;
|
||||
if (inDto.VisistTaskId == null)
|
||||
{
|
||||
noneDicomStudyQueryable = _noneDicomStudyRepository
|
||||
.Where(t => visitIds.Contains(t.SubjectVisitId) && t.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip)))
|
||||
.WhereIf(taskinfo.IsImageFilter == true, t => taskinfo.CriterionModalitys.Contains(t.Modality))
|
||||
.ProjectTo<NoneDicomStudyView>(_mapper.ConfigurationProvider, new { isFilterZip = true });
|
||||
}
|
||||
else
|
||||
{
|
||||
noneDicomStudyQueryable = _noneDicomStudyRepository.Where(t => t.TaskNoneDicomFileList.Any(t => t.VisitTaskId == inDto.VisistTaskId))
|
||||
.Where(t => visitIds.Contains(t.SubjectVisitId))
|
||||
.ProjectTo<TaskDicomStudyView>(_mapper.ConfigurationProvider, new { isFilterZip = true, visiTaskId = inDto.VisistTaskId });
|
||||
}
|
||||
List<NoneDicomStudyView> result = await noneDicomStudyQueryable.ToListAsync();
|
||||
|
||||
|
||||
var trialInfo = await _trialRepository.Where(x => x.Id == inDto.TrialId).Select(x => new
|
||||
{
|
||||
|
@ -121,7 +138,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == task.VisitTaskId).FirstNotNullAsync();
|
||||
|
||||
return ResponseOutput.Ok (result, new
|
||||
return ResponseOutput.Ok(result, new
|
||||
{
|
||||
VisitTaskId = task.VisitTaskId,
|
||||
SubjectId = task.SubjectId,
|
||||
|
|
|
@ -654,7 +654,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
|
||||
var query = subjectVisitQuery.Union(readMouduleQuery)
|
||||
.WhereIf(inQuery.SubjectId != null, x => x.Id == inQuery.SubjectId)
|
||||
.WhereIf(inQuery.SubjectId != null, x => x.SubjectId == inQuery.SubjectId)
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.TrialSiteCode), x => x.TrialSiteCode.Contains(inQuery.TrialSiteCode))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectCode), x => x.SubjectCode.Contains(inQuery.SubjectCode))
|
||||
.WhereIf(isFilterModuleType, t => t.ModuleType == inQuery.ModuleType)
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace IRaCIS.Application.Services
|
|||
.WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId)
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserRealName), t => (t.User.FullName).Contains(inQuery.UserRealName))
|
||||
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.OrganizationName), t => t.User.OrganizationName.Contains(inQuery.OrganizationName))
|
||||
.ProjectTo<AssginSiteCRCListDTO>(_mapper.ConfigurationProvider, new { trialSiteId = inQuery.TrialSiteId });
|
||||
.ProjectTo<AssginSiteCRCListDTO>(_mapper.ConfigurationProvider);
|
||||
|
||||
return await query.ToPagedListAsync(inQuery);
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
.ForMember(d => d.UserRealName, u => u.MapFrom(s => s.User.FullName))
|
||||
.ForMember(d => d.TrialSiteId, u => u.MapFrom(t => trialSiteId))
|
||||
.ForMember(d => d.UserType, u => u.MapFrom(t => t.User.UserTypeRole.UserTypeShortName))
|
||||
.ForMember(d => d.IsSelect, u => u.MapFrom(t => t.SiteList.Any(k => k.TrialSiteId == trialSiteId)));
|
||||
.ForMember(d => d.IsSelect, u => u.MapFrom(t => t.Trial.TrialSiteUserList.Any(k => k.UserId == t.UserId)));
|
||||
CreateMap<User, AssginSiteCRCListDTO>();
|
||||
|
||||
var trialId = Guid.Empty;
|
||||
|
|
|
@ -186,8 +186,11 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
|
||||
public class GetReadingVisitStudyListIndto
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid TrialId { get; set; }
|
||||
[NotDefault]
|
||||
public Guid SujectVisitId { get; set; }
|
||||
[NotDefault]
|
||||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
IRepository<ReadingQuestionCriterionTrial> _trialReadingCriterionRepository
|
||||
) : BaseService, ISubjectVisitService
|
||||
{
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
|
||||
|
@ -541,7 +541,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
SeriesId = x.SeriesId,
|
||||
StudyId = x.StudyId,
|
||||
InstanceId = x.InstanceId,
|
||||
NumberOfFrames=x.NumberOfFrames,
|
||||
NumberOfFrames = x.NumberOfFrames,
|
||||
}).ToListAsync();
|
||||
|
||||
|
||||
|
@ -594,20 +594,20 @@ namespace IRaCIS.Core.Application.Services
|
|||
HtmlPath = k.HtmlPath,
|
||||
Path = k.Path,
|
||||
InstanceNumber = k.InstanceNumber,
|
||||
StudyId= k.StudyId,
|
||||
SeriesId= k.SeriesId,
|
||||
StudyId = k.StudyId,
|
||||
SeriesId = k.SeriesId,
|
||||
}).ToListAsync();
|
||||
|
||||
item.InstanceInfoList.ForEach(x =>
|
||||
{
|
||||
|
||||
var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id&&y.NumberOfFrames!=0).Select(y => y.NumberOfFrames).Distinct().ToList();
|
||||
var keyFramesList = rowInfoList.Where(y => y.InstanceId == x.Id && y.NumberOfFrames != 0).Select(y => y.NumberOfFrames).Distinct().ToList();
|
||||
|
||||
if (keyFramesList.Count() > 0)
|
||||
{
|
||||
x.KeyFramesList = keyFramesList;
|
||||
}
|
||||
|
||||
|
||||
var item = rowInfoList.FirstOrDefault(y => y.InstanceId == x.Id);
|
||||
if (item != null)
|
||||
{
|
||||
|
@ -632,7 +632,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
|
||||
|
||||
|
||||
studyList.Insert(0,thisVisitTaskStudy);
|
||||
studyList.Insert(0, thisVisitTaskStudy);
|
||||
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
#region 非Dicom 检查查询
|
||||
|
||||
var noDicomList = await _noneDicomStudyRepository.Where(x => x.TrialId == indto.TrialId && x.SubjectVisitId == indto.SujectVisitId && x.NoneDicomFileList.Any(t => !t.FileType.Contains(StaticData.FileType.Zip)))
|
||||
.WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality) ).ToListAsync();
|
||||
.WhereIf(taskInfo.IsImageFilter == true, t => taskInfo.CriterionModalitys.Contains(t.Modality)).ToListAsync();
|
||||
|
||||
|
||||
List<VisitStudyDTO> noDicomStudyList = noDicomList.Select(x => new VisitStudyDTO()
|
||||
|
@ -672,11 +672,14 @@ namespace IRaCIS.Core.Application.Services
|
|||
|
||||
}).ToList();
|
||||
|
||||
var isExistTaskNoneDicomFile = _noneDicomStudyFileRepository.Any(t => t.VisitTaskId == indto.VisitTaskId);
|
||||
|
||||
foreach (var item in noDicomStudyList)
|
||||
{
|
||||
var nodicom = noDicomList.Where(x => x.Id == item.StudyId).First();
|
||||
|
||||
var instanceCount = await _noneDicomStudyFileRepository.Where(x => x.NoneDicomStudyId == item.StudyId).CountAsync();
|
||||
var instanceCount = await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId)
|
||||
.WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId).CountAsync();
|
||||
|
||||
if (instanceCount == 0)
|
||||
{
|
||||
|
@ -697,7 +700,9 @@ namespace IRaCIS.Core.Application.Services
|
|||
SubjectVisitId=nodicom.SubjectVisitId,
|
||||
SubjectId=nodicom.SubjectId,
|
||||
SeriesNumber=1,
|
||||
NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.Where(x=>x.NoneDicomStudyId==item.StudyId && !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(),
|
||||
NoneDicomFileFirstFile=await _noneDicomStudyFileRepository.WhereIf(isExistTaskNoneDicomFile,x=>x.OriginNoneDicomStudyId== item.StudyId)
|
||||
.WhereIf(isExistTaskNoneDicomFile==false, x=>x.NoneDicomStudyId == item.StudyId)
|
||||
.Where(x=> !x.FileType.Contains(StaticData.FileType.Zip)).Select(x=>x.Path).FirstOrDefaultAsync(),
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
[JsonIgnore]
|
||||
//Parent
|
||||
[ForeignKey("OrignalSubjectUserId")]
|
||||
public SubjectUser OrignalSubjectUser { get; set; }
|
||||
[ForeignKey("ReplacedSubjectUserId")]
|
||||
public SubjectUser ReplacedSubjectUser { get; set; }
|
||||
|
||||
//ChildList
|
||||
[JsonIgnore]
|
||||
|
@ -34,6 +34,9 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
[JsonIgnore]
|
||||
public User DoctorUser { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Subject Subject { get; set; }
|
||||
#endregion
|
||||
|
||||
public Guid TrialId { get; set; }
|
||||
|
@ -44,8 +47,6 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
public Subject Subject { get; set; }
|
||||
|
||||
|
||||
public Guid DoctorUserId { get; set; }
|
||||
|
||||
|
@ -55,7 +56,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public bool IsConfirmed { get; set; } = true;
|
||||
|
||||
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
||||
public Guid? OrignalSubjectUserId { get; set; }
|
||||
public Guid? ReplacedSubjectUserId { get; set; }
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
#region 导航属性
|
||||
[JsonIgnore]
|
||||
public VisitTask OriginalTask { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public VisitTask InfluenceTask { get; set; }
|
||||
#endregion
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public VisitTask VisitTask { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public List<string> ScreenshotList => JsonConvert.DeserializeObject<List<string>>(ScreenshotListStr);
|
||||
public List<string> FeedBackScreenshotList => JsonConvert.DeserializeObject<List<string>>(ScreenshotListStr);
|
||||
#endregion
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DicomStudy? DicomStudy { get; set; }
|
||||
[ForeignKey("StudyId")]
|
||||
public DicomStudy DicomStudy { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("TrialId")]
|
||||
|
|
|
@ -21,8 +21,8 @@ namespace IRaCIS.Core.Domain.Models
|
|||
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
|
||||
public DicomStudy? DicomStudy { get; set; }
|
||||
[ForeignKey("StudyId")]
|
||||
public DicomStudy DicomStudy { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("TrialId")]
|
||||
|
|
|
@ -27,8 +27,7 @@ namespace IRaCIS.Core.Domain.Models
|
|||
|
||||
[JsonIgnore]
|
||||
public TrialSite TrialSite { get; set; }
|
||||
[JsonIgnore]
|
||||
public TrialUser TrialUser { get; set; }
|
||||
|
||||
#endregion
|
||||
public Guid TrialSiteId { get; set; }
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ namespace IRaCIS.Core.Domain.Models
|
|||
[JsonIgnore]
|
||||
[ForeignKey("UserId")]
|
||||
public User User { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public List<TrialSiteUser> SiteList { get; set; }
|
||||
#endregion
|
||||
public Guid UserId { get; set; }
|
||||
public Guid TrialId { get; set; }
|
||||
|
|
|
@ -16,8 +16,6 @@ namespace IRaCIS.Core.Domain.Models
|
|||
[JsonIgnore]
|
||||
public TrialSite TrialSite { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public VisitStage VisitStage { get; set; }
|
||||
[JsonIgnore]
|
||||
[ForeignKey("OutPlanPreviousVisitId")]
|
||||
public SubjectVisit OutPlanPreviousVisit { get; set; }
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class DoctorConfigration : IEntityTypeConfiguration<DoctorDictionary>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<DoctorDictionary> builder)
|
||||
{
|
||||
builder
|
||||
.HasOne(dd => dd.Doctor)
|
||||
.WithMany(p => p.DoctorDicRelationList)
|
||||
.HasForeignKey(dd => dd.DoctorId);
|
||||
|
||||
builder
|
||||
.HasOne(dd => dd.Dictionary)
|
||||
.WithMany(d => d.DoctorDicRelationList)
|
||||
.HasForeignKey(dd => dd.DictionaryId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class NoneDicomStudyConfigration : IEntityTypeConfiguration<NoneDicomStudy>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<NoneDicomStudy> builder)
|
||||
{
|
||||
|
||||
builder.HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId);
|
||||
builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class ReadModuleConfigration : IEntityTypeConfiguration<ReadModule>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<ReadModule> builder)
|
||||
{
|
||||
|
||||
builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
|
||||
public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration<ReadingQuestionTrial>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<ReadingQuestionTrial> builder)
|
||||
{
|
||||
|
||||
|
||||
builder.HasQueryFilter(p => p.IsAdditional == false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,27 +5,38 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class StudyConfigration : IEntityTypeConfiguration<DicomStudy>
|
||||
{
|
||||
|
||||
//public class StudyConfigration : IEntityTypeConfiguration<DicomStudy>
|
||||
//{
|
||||
|
||||
public void Configure(EntityTypeBuilder<DicomStudy> builder)
|
||||
{
|
||||
|
||||
// /// <summary>
|
||||
// /// 一个外键,关联多个表 ReadingId
|
||||
// /// </summary>
|
||||
// /// <param name="builder"></param>
|
||||
// public void Configure(EntityTypeBuilder<DicomStudy> builder)
|
||||
// {
|
||||
|
||||
builder
|
||||
.HasMany(s => s.ReadingClinicalDataList)
|
||||
.WithOne(c => c.DicomStudy)
|
||||
.HasForeignKey(s => new { s.StudyId })
|
||||
.HasPrincipalKey(c => new { c.Id });
|
||||
// builder
|
||||
// .HasMany(s => s.ReadingClinicalDataList)
|
||||
// .WithOne(c => c.DicomStudy)
|
||||
// .HasForeignKey(s => new { s.StudyId })
|
||||
// .HasPrincipalKey(c => new { c.Id });
|
||||
|
||||
|
||||
builder
|
||||
.HasMany(s => s.ReadingConsistentClinicalDataList)
|
||||
.WithOne(c => c.DicomStudy)
|
||||
.HasForeignKey(s => new { s.StudyId })
|
||||
.HasPrincipalKey(c => new { c.Id });
|
||||
// builder
|
||||
// .HasMany(s => s.ReadingConsistentClinicalDataList)
|
||||
// .WithOne(c => c.DicomStudy)
|
||||
// .HasForeignKey(s => new { s.StudyId })
|
||||
// .HasPrincipalKey(c => new { c.Id });
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
//public class UserConfigration : IEntityTypeConfiguration<User>
|
||||
//{
|
||||
// public void Configure(EntityTypeBuilder<User> builder)
|
||||
// {
|
||||
// //对于阅片人来讲,会有很多任务
|
||||
// builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -6,16 +6,44 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class SubjectConfigration : IEntityTypeConfiguration<Subject>
|
||||
{
|
||||
|
||||
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Subject> builder)
|
||||
{
|
||||
|
||||
//不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置
|
||||
builder.HasOne(s => s.LatestSubjectVisit);
|
||||
builder.HasOne(s => s.FinalSubjectVisit);
|
||||
builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject);
|
||||
builder.HasOne(s => s.LatestSubjectVisit).WithMany().HasForeignKey(t => t.LatestSubjectVisitId);
|
||||
builder.HasOne(s => s.FinalSubjectVisit).WithMany().HasForeignKey(t => t.FinalSubjectVisitId);
|
||||
builder.HasMany(s => s.SubjectVisitList).WithOne(sv => sv.Subject).HasForeignKey(t => t.SubjectId);
|
||||
}
|
||||
}
|
||||
public class DictionaryConfigration : IEntityTypeConfiguration<Dictionary>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Dictionary> builder)
|
||||
{
|
||||
|
||||
//自身同时存在一对多 和一对一的关系,配置一对多的就可以,一对一 不用配置,有点奇怪
|
||||
builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class NoneDicomStudyConfigration : IEntityTypeConfiguration<NoneDicomStudy>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<NoneDicomStudy> builder)
|
||||
{
|
||||
//同样一个实体 有两个相同的类型的导航属性,需要手动配置
|
||||
builder.HasMany(t => t.NoneDicomFileList).WithOne(s => s.NoneDicomStudy).HasForeignKey(t => t.NoneDicomStudyId);
|
||||
builder.HasMany(t => t.TaskNoneDicomFileList).WithOne(s => s.OriginNoneDicomStudy).HasForeignKey(t => t.OriginNoneDicomStudyId);
|
||||
}
|
||||
}
|
||||
|
||||
public class SubjectUserConfigration : IEntityTypeConfiguration<SubjectUser>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SubjectUser> builder)
|
||||
{
|
||||
//自身存在一对多的关系
|
||||
//对于替换后的医生而言,关联多个之前的医生
|
||||
builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.ReplacedSubjectUser).HasForeignKey(t => t.ReplacedSubjectUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
public class SubjectVisitConfigration : IEntityTypeConfiguration<SubjectVisit>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SubjectVisit> builder)
|
||||
{
|
||||
|
||||
builder.HasOne(s => s.Subject).WithMany(sv => sv.SubjectVisitList);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
{
|
||||
|
||||
public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration<SubjectCriteriaEvaluation>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<SubjectCriteriaEvaluation> builder)
|
||||
{
|
||||
builder
|
||||
.HasMany(s => s.SubjectCriteriaEvaluationVisitFilterList)
|
||||
.WithOne(c => c.SubjectCriteriaEvaluation)
|
||||
.HasForeignKey(s => new { s.SubjectId, s.TrialReadingCriterionId })
|
||||
.HasPrincipalKey(c => new { c.SubjectId, c.TrialReadingCriterionId });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -6,29 +6,20 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
|||
{
|
||||
|
||||
|
||||
public class TrialUserConfigration : IEntityTypeConfiguration<TrialUser>
|
||||
|
||||
public class SubjectCriteriaEvaluationConfigration : IEntityTypeConfiguration<SubjectCriteriaEvaluation>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<TrialUser> builder)
|
||||
public void Configure(EntityTypeBuilder<SubjectCriteriaEvaluation> builder)
|
||||
{
|
||||
builder
|
||||
.HasMany(s => s.SiteList)
|
||||
.WithOne(c => c.TrialUser)
|
||||
.HasForeignKey(s => new { s.TrialId, s.UserId })
|
||||
.HasPrincipalKey(c => new { c.TrialId, c.UserId });
|
||||
.HasMany(s => s.SubjectCriteriaEvaluationVisitFilterList)
|
||||
.WithOne(c => c.SubjectCriteriaEvaluation)
|
||||
.HasForeignKey(s => new { s.SubjectId, s.TrialReadingCriterionId })
|
||||
.HasPrincipalKey(c => new { c.SubjectId, c.TrialReadingCriterionId });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class UserConfigration : IEntityTypeConfiguration<User>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<User> builder)
|
||||
{
|
||||
builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,46 +12,31 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
|||
|
||||
public void Configure(EntityTypeBuilder<VisitTask> builder)
|
||||
{
|
||||
//对于裁判任务而言,一个裁判任务,关联了两个产生裁判的任务
|
||||
builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask).HasForeignKey(t => t.JudgeVisitTaskId);
|
||||
|
||||
builder.HasMany(t => t.JudgeVisitList).WithOne(t => t.JudgeVisitTask);
|
||||
|
||||
|
||||
builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId);
|
||||
|
||||
builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId);
|
||||
|
||||
//对于退回或者重阅的任务而已,会关联多个影响的任务
|
||||
builder.HasMany(t => t.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId);
|
||||
|
||||
|
||||
//对于全局任务而言,会关联多个全局访视阅片结果(因为同一全局会对多个访视的结果进行修改)
|
||||
builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId);
|
||||
//对于全局修改的任务而言,会关联多个全局访视阅片结果(因为同一个访视结果,会被多个全局修改)
|
||||
|
||||
|
||||
|
||||
//subject 删除了,但是任务没删除,导致的查询问题
|
||||
builder.HasQueryFilter(b => b.Subject.IsDeleted == false);
|
||||
|
||||
|
||||
//modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.DoctorTrialVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
|
||||
|
||||
//modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
|
||||
|
||||
//会导致级联删除
|
||||
//modelBuilder.Entity<SubjectUser>().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t => t.SujectArm).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum })
|
||||
// ./*IsRequired(false)*/OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
// builder.HasOne(t => t.SujectArm).WithMany(s => s.SubjectArmVisitTaskList).HasForeignKey(t => new { t.SubjectId, t.ArmEnum }).HasPrincipalKey(u => new { u.SubjectId, u.ArmEnum });
|
||||
|
||||
|
||||
//builder.HasOne(t => t.Subject).WithMany(s => s.SubjectVisitTaskList).HasForeignKey(t => t.SubjectId);
|
||||
//builder.HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.VisitTask).HasForeignKey(t => t.VisitTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
public class SubjectUserConfigration : IEntityTypeConfiguration<SubjectUser>
|
||||
public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration<ReadingQuestionTrial>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SubjectUser> builder)
|
||||
public void Configure(EntityTypeBuilder<ReadingQuestionTrial> builder)
|
||||
{
|
||||
builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);
|
||||
//不影响之前的逻辑,附加评估
|
||||
builder.HasQueryFilter(p => p.IsAdditional == false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,22 @@
|
|||
#参考学习文档
|
||||
https://www.cnblogs.com/cqpanda/p/16815263.html
|
||||
|
||||
# 如果不想指定项目名称,需要进入项目目录 一般pwershell进入的是项目根目录,需要命令指定项目
|
||||
cd .\IRaCIS.Core.Test
|
||||
|
||||
# 该目录下如果有多个上下文,需要手动指定
|
||||
|
||||
# dotnet ef migrations add 签名名字 -p 项目名 -c 上下文名 -o 迁移文件生成目录
|
||||
|
||||
1、生成迁移文件
|
||||
dotnet ef migrations add Initial -p IRaCIS.Core.Test -c IRCContext -o CodeFirstTest/MSSQL/Migrations
|
||||
|
||||
dotnet ef database update -p IRaCIS.Core.Test -c IRCContext
|
||||
2、撤销刚才生成的迁移文件
|
||||
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
3、将迁移文件更新到数据库
|
||||
dotnet ef database update -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
4、查看已有迁移
|
||||
dotnet ef migrations list -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
5、撤销某次更新到数据库的迁移
|
||||
dotnet ef database update 某次迁移的前一次迁移名称 -p IRaCIS.Core.Test -c IRCContext
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||
{
|
||||
public class DictionaryConfigration : IEntityTypeConfiguration<Dictionary>
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
|||
{
|
||||
|
||||
|
||||
builder.HasMany(t => t.ChildList).WithOne(t => t.Parent);
|
||||
builder.HasMany(t => t.ChildList).WithOne(t => t.Parent).HasForeignKey(d => d.ParentId);
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||
{
|
||||
public class SubjectConfigration : IEntityTypeConfiguration<Subject>
|
||||
{
|
||||
|
||||
|
||||
public void Configure(EntityTypeBuilder<Subject> builder)
|
||||
{
|
||||
|
||||
//不能同时配置一对多 和一对一 但是有时表要存储多的最新的 比如受试者 最新的访视 在这里要显示配置
|
||||
builder.HasOne(s => s.LatestSubjectVisit);
|
||||
builder.HasOne(s => s.FinalSubjectVisit);
|
||||
builder.HasMany(s => s.SubejectVisitList).WithOne(sv => sv.Subject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using IRaCIS.Core.Test.CodeFirstTest.MSSQL;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
|
@ -24,13 +26,23 @@ public partial class IRCContext : DbContext
|
|||
|
||||
public virtual DbSet<SubejectVisit> SubejectVisit { get; set; }
|
||||
|
||||
public virtual DbSet<Dictionary> Dictionary { get; set; }
|
||||
public virtual DbSet<ReadingClinicalData> ReadingClinicalData { get; set; }
|
||||
public virtual DbSet<ReadModule> ReadModule { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
//遍历实体模型手动配置
|
||||
var typesToRegister = Assembly.GetExecutingAssembly().GetTypes().Where(q => q.GetInterface(typeof(IEntityTypeConfiguration<>).FullName) != null);
|
||||
foreach (var type in typesToRegister)
|
||||
{
|
||||
dynamic configurationInstance = Activator.CreateInstance(type);
|
||||
modelBuilder.ApplyConfiguration(configurationInstance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
|
213
IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs
generated
Normal file
213
IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910073024_oneToManyAndOneToOne.Designer.cs
generated
Normal file
|
@ -0,0 +1,213 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using IRaCIS.Core.Test.CodeFirstTest.MSSQL;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
||||
{
|
||||
[DbContext(typeof(IRCContext))]
|
||||
[Migration("20240910073024_oneToManyAndOneToOne")]
|
||||
partial class oneToManyAndOneToOne
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("SubjectId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SubjectId");
|
||||
|
||||
b.ToTable("SubejectVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("FinalSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("LatestSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FinalSubjectVisitId");
|
||||
|
||||
b.HasIndex("LatestSubjectVisitId");
|
||||
|
||||
b.ToTable("Subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("TestName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<Guid>("TrialImageDownloadId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TrialImageDownloadId");
|
||||
|
||||
b.ToTable("TestNew");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("DownloadEndTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DownloadStartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ImageCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("ImageSize")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("ImageType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsSuccess")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<Guid>("SubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TrialImageDownload");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject")
|
||||
.WithMany("SubejectVisitList")
|
||||
.HasForeignKey("SubjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("FinalSubjectVisitId");
|
||||
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("LatestSubjectVisitId");
|
||||
|
||||
b.Navigation("FinalSubjectVisit");
|
||||
|
||||
b.Navigation("LatestSubjectVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null)
|
||||
.WithMany("TestNewList")
|
||||
.HasForeignKey("TrialImageDownloadId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Navigation("SubejectVisitList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
{
|
||||
b.Navigation("TestNewList");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class oneToManyAndOneToOne : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SubejectVisit",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
SubjectId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SubejectVisit", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Subject",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LatestSubjectVisitId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
FinalSubjectVisitId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Subject", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Subject_SubejectVisit_FinalSubjectVisitId",
|
||||
column: x => x.FinalSubjectVisitId,
|
||||
principalTable: "SubejectVisit",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Subject_SubejectVisit_LatestSubjectVisitId",
|
||||
column: x => x.LatestSubjectVisitId,
|
||||
principalTable: "SubejectVisit",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SubejectVisit_SubjectId",
|
||||
table: "SubejectVisit",
|
||||
column: "SubjectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Subject_FinalSubjectVisitId",
|
||||
table: "Subject",
|
||||
column: "FinalSubjectVisitId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Subject_LatestSubjectVisitId",
|
||||
table: "Subject",
|
||||
column: "LatestSubjectVisitId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_SubejectVisit_Subject_SubjectId",
|
||||
table: "SubejectVisit",
|
||||
column: "SubjectId",
|
||||
principalTable: "Subject",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_SubejectVisit_Subject_SubjectId",
|
||||
table: "SubejectVisit");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Subject");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SubejectVisit");
|
||||
}
|
||||
}
|
||||
}
|
269
IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs
generated
Normal file
269
IRaCIS.Core.Test/CodeFirstTest/MSSQL/Migrations/20240910075136_seftOneToManyAndOneToOne.Designer.cs
generated
Normal file
|
@ -0,0 +1,269 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using IRaCIS.Core.Test.CodeFirstTest.MSSQL;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
||||
{
|
||||
[DbContext(typeof(IRCContext))]
|
||||
[Migration("20240910075136_seftOneToManyAndOneToOne")]
|
||||
partial class seftOneToManyAndOneToOne
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("ConfigTypeId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("ParentId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConfigTypeId");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.ToTable("Dictionary");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("SubjectId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SubjectId");
|
||||
|
||||
b.ToTable("SubejectVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("FinalSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("LatestSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FinalSubjectVisitId");
|
||||
|
||||
b.HasIndex("LatestSubjectVisitId");
|
||||
|
||||
b.ToTable("Subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("TestName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)");
|
||||
|
||||
b.Property<Guid>("TrialImageDownloadId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TrialImageDownloadId");
|
||||
|
||||
b.ToTable("TestNew");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime?>("DownloadEndTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DownloadStartTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ImageCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<long>("ImageSize")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("ImageType")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<bool>("IsSuccess")
|
||||
.HasColumnType("bit");
|
||||
|
||||
b.Property<Guid>("SubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TrialImageDownload");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigTypeId");
|
||||
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent")
|
||||
.WithMany("ChildList")
|
||||
.HasForeignKey("ParentId");
|
||||
|
||||
b.Navigation("ConfigType");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject")
|
||||
.WithMany("SubejectVisitList")
|
||||
.HasForeignKey("SubjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("FinalSubjectVisitId");
|
||||
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("LatestSubjectVisitId");
|
||||
|
||||
b.Navigation("FinalSubjectVisit");
|
||||
|
||||
b.Navigation("LatestSubjectVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", null)
|
||||
.WithMany("TestNewList")
|
||||
.HasForeignKey("TrialImageDownloadId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.Navigation("ChildList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Navigation("SubejectVisitList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
{
|
||||
b.Navigation("TestNewList");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class seftOneToManyAndOneToOne : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Dictionary",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
ConfigTypeId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
|
||||
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
|
||||
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Dictionary", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Dictionary_Dictionary_ConfigTypeId",
|
||||
column: x => x.ConfigTypeId,
|
||||
principalTable: "Dictionary",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Dictionary_Dictionary_ParentId",
|
||||
column: x => x.ParentId,
|
||||
principalTable: "Dictionary",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Dictionary_ConfigTypeId",
|
||||
table: "Dictionary",
|
||||
column: "ConfigTypeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Dictionary_ParentId",
|
||||
table: "Dictionary",
|
||||
column: "ParentId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Dictionary");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,105 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
|||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Code")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<Guid?>("ConfigTypeId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("ParentId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConfigTypeId");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.ToTable("Dictionary", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid>("SubjectId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SubjectId");
|
||||
|
||||
b.ToTable("SubejectVisit", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("CreateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("FinalSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<Guid?>("LatestSubjectVisitId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<Guid>("UpdateUserId")
|
||||
.HasColumnType("uniqueidentifier");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FinalSubjectVisitId");
|
||||
|
||||
b.HasIndex("LatestSubjectVisitId");
|
||||
|
||||
b.ToTable("Subject", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
@ -51,7 +150,7 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
|||
|
||||
b.HasIndex("TrialImageDownloadId");
|
||||
|
||||
b.ToTable("TestNew");
|
||||
b.ToTable("TestNew", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
|
@ -94,7 +193,48 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
|||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("TrialImageDownload");
|
||||
b.ToTable("TrialImageDownload", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "ConfigType")
|
||||
.WithMany()
|
||||
.HasForeignKey("ConfigTypeId");
|
||||
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", "Parent")
|
||||
.WithMany("ChildList")
|
||||
.HasForeignKey("ParentId");
|
||||
|
||||
b.Navigation("ConfigType");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", "Subject")
|
||||
.WithMany("SubejectVisitList")
|
||||
.HasForeignKey("SubjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Subject");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "FinalSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("FinalSubjectVisitId");
|
||||
|
||||
b.HasOne("IRaCIS.Core.Test.CodeFirstTest.MSSQL.SubejectVisit", "LatestSubjectVisit")
|
||||
.WithMany()
|
||||
.HasForeignKey("LatestSubjectVisitId");
|
||||
|
||||
b.Navigation("FinalSubjectVisit");
|
||||
|
||||
b.Navigation("LatestSubjectVisit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TestNew", b =>
|
||||
|
@ -106,6 +246,16 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL.Migrations
|
|||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Dictionary", b =>
|
||||
{
|
||||
b.Navigation("ChildList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.Subject", b =>
|
||||
{
|
||||
b.Navigation("SubejectVisitList");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IRaCIS.Core.Test.CodeFirstTest.MSSQL.TrialImageDownload", b =>
|
||||
{
|
||||
b.Navigation("TestNewList");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
@ -48,7 +49,7 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
|||
}
|
||||
|
||||
|
||||
public class Subject: BaseFullAuditEntity
|
||||
public class Subject : BaseFullAuditEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -59,8 +60,10 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
|||
|
||||
#region 同时配置一对多,一对一 导航属性
|
||||
|
||||
[ForeignKey("FinalSubjectVisitId")]
|
||||
public SubejectVisit FinalSubjectVisit { get; set; }
|
||||
|
||||
[ForeignKey("LatestSubjectVisitId")]
|
||||
public SubejectVisit LatestSubjectVisit { get; set; }
|
||||
|
||||
public List<SubejectVisit> SubejectVisitList { get; set; }
|
||||
|
@ -68,11 +71,61 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
|||
|
||||
}
|
||||
|
||||
public class SubejectVisit: BaseFullAuditEntity
|
||||
public class SubejectVisit : BaseFullAuditEntity
|
||||
{
|
||||
public Subject Subject { get; set; }
|
||||
|
||||
|
||||
public Guid SubjectId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class Dictionary : BaseFullAuditEntity
|
||||
{
|
||||
#region 导航属性
|
||||
[ForeignKey("ConfigTypeId")]
|
||||
public Dictionary ConfigType { get; set; }
|
||||
|
||||
[ForeignKey("ParentId")]
|
||||
public Dictionary Parent { get; set; }
|
||||
|
||||
public List<Dictionary> ChildList { get; set; } = new List<Dictionary>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public Guid? ParentId { get; set; }
|
||||
|
||||
|
||||
public Guid? ConfigTypeId { get; set; }
|
||||
|
||||
public string Code { get; set; }
|
||||
}
|
||||
|
||||
#region 一个外键 关联两个实体
|
||||
public class ReadingClinicalData : BaseFullAuditEntity
|
||||
{
|
||||
public string Code { get; set; }
|
||||
|
||||
|
||||
public Guid ReadingId { get; set; }
|
||||
|
||||
|
||||
[ForeignKey("ReadingId")]
|
||||
|
||||
public SubejectVisit SubjectVisit { get; set; }
|
||||
|
||||
[ForeignKey("ReadingId")]
|
||||
|
||||
public ReadModule ReadModule { get; set; }
|
||||
}
|
||||
|
||||
public class ReadModule : BaseFullAuditEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputEncoding>utf-8</OutputEncoding>
|
||||
<ConsoleOutputEncoding>utf-8</ConsoleOutputEncoding>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
|
Loading…
Reference in New Issue