维护导航属性,重命名字段
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
3f38cf25c5
commit
5e1ec1ffb2
|
@ -602,9 +602,9 @@ namespace IRaCIS.Core.Application.ViewModel
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<SubjectUserView> DoctorUserList { get; set; }
|
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 bool IsConfirmed { get; set; }
|
||||||
|
|
||||||
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
//该属性有值 说明该医生被替换了 分配的时候 要过滤掉
|
||||||
public Guid? OrignalSubjectUserId { get; set; }
|
public Guid? ReplacedSubjectUserId { get; set; }
|
||||||
|
|
||||||
public UserSimpleInfo DoctorUser { 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() }))
|
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 isNeedClinicalDataSign = IsNeedClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList);
|
||||||
var isClinicalDataSign = IsClinicalDataSign(ReadingCategory.Visit, subjectVisit.IsBaseLine, trialReadingCriterionConfig.TrialReadingCriterionId, clinicalDataConfirmList, subjectVisit.Id, trialId);
|
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)
|
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 });
|
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>
|
/// <returns></returns>
|
||||||
public async Task<(List<SubjectUserDTO>, object)> GetSubjectAssignedDoctorList(Guid subjectId, Guid trialReadingCriterionId)
|
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();
|
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;
|
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组已有该医生,不允许在新的组添加该医生
|
//---有Subject 在其他Arm组已有该医生,不允许在新的组添加该医生
|
||||||
throw new BusinessValidationFailedException(_localizer["VisitTask_InconsistentSubjectStatus"]);
|
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组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期
|
//---有Subject 已有该Arm组的医生,不允许继续分配,请刷新页面,确认页面数据是否过期
|
||||||
throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]);
|
throw new BusinessValidationFailedException(_localizer["VisitTask_DuplicateDoctorInArm"]);
|
||||||
|
@ -568,11 +568,11 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
||||||
//将关系确认
|
//将关系确认
|
||||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
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
|
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 });
|
&& subjectIdList.Contains(t.SubjectId), u => new SubjectUser() { IsConfirmed = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +597,7 @@ namespace IRaCIS.Core.Application.Service.Allocation
|
||||||
|
|
||||||
if (assignConfirmCommand.SubjectDoctorUserList.Count == 0)
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
//Parent
|
//Parent
|
||||||
[ForeignKey("OrignalSubjectUserId")]
|
[ForeignKey("ReplacedSubjectUserId")]
|
||||||
public SubjectUser OrignalSubjectUser { get; set; }
|
public SubjectUser ReplacedSubjectUser { get; set; }
|
||||||
|
|
||||||
//ChildList
|
//ChildList
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
@ -34,6 +34,9 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public User DoctorUser { get; set; }
|
public User DoctorUser { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public Subject Subject { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public Guid TrialId { get; set; }
|
public Guid TrialId { get; set; }
|
||||||
|
@ -44,8 +47,6 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
|
|
||||||
public Guid SubjectId { get; set; }
|
public Guid SubjectId { get; set; }
|
||||||
|
|
||||||
public Subject Subject { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public Guid DoctorUserId { get; set; }
|
public Guid DoctorUserId { get; set; }
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public bool IsConfirmed { get; set; } = true;
|
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 导航属性
|
#region 导航属性
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public VisitTask OriginalTask { get; set; }
|
public VisitTask OriginalTask { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public VisitTask InfluenceTask { get; set; }
|
public VisitTask InfluenceTask { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -22,7 +22,8 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public DicomStudy? DicomStudy { get; set; }
|
[ForeignKey("StudyId")]
|
||||||
|
public DicomStudy DicomStudy { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[ForeignKey("TrialId")]
|
[ForeignKey("TrialId")]
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace IRaCIS.Core.Domain.Models
|
||||||
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
[ForeignKey("StudyId")]
|
||||||
public DicomStudy? DicomStudy { get; set; }
|
public DicomStudy DicomStudy { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[ForeignKey("TrialId")]
|
[ForeignKey("TrialId")]
|
||||||
|
|
|
@ -5,39 +5,38 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||||
{
|
{
|
||||||
public class StudyConfigration : IEntityTypeConfiguration<DicomStudy>
|
//public class StudyConfigration : IEntityTypeConfiguration<DicomStudy>
|
||||||
{
|
//{
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// 一个外键,关联多个表
|
// /// 一个外键,关联多个表 ReadingId
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="builder"></param>
|
// /// <param name="builder"></param>
|
||||||
public void Configure(EntityTypeBuilder<DicomStudy> builder)
|
// public void Configure(EntityTypeBuilder<DicomStudy> builder)
|
||||||
{
|
// {
|
||||||
|
|
||||||
builder
|
// builder
|
||||||
.HasMany(s => s.ReadingClinicalDataList)
|
// .HasMany(s => s.ReadingClinicalDataList)
|
||||||
.WithOne(c => c.DicomStudy)
|
// .WithOne(c => c.DicomStudy)
|
||||||
.HasForeignKey(s => new { s.StudyId })
|
// .HasForeignKey(s => new { s.StudyId })
|
||||||
.HasPrincipalKey(c => new { c.Id });
|
// .HasPrincipalKey(c => new { c.Id });
|
||||||
|
|
||||||
|
|
||||||
builder
|
// builder
|
||||||
.HasMany(s => s.ReadingConsistentClinicalDataList)
|
// .HasMany(s => s.ReadingConsistentClinicalDataList)
|
||||||
.WithOne(c => c.DicomStudy)
|
// .WithOne(c => c.DicomStudy)
|
||||||
.HasForeignKey(s => new { s.StudyId })
|
// .HasForeignKey(s => new { s.StudyId })
|
||||||
.HasPrincipalKey(c => new { c.Id });
|
// .HasPrincipalKey(c => new { c.Id });
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
public class ReadModuleConfigration : IEntityTypeConfiguration<ReadModule>
|
//public class UserConfigration : IEntityTypeConfiguration<User>
|
||||||
{
|
//{
|
||||||
|
// public void Configure(EntityTypeBuilder<User> builder)
|
||||||
public void Configure(EntityTypeBuilder<ReadModule> builder)
|
// {
|
||||||
{
|
// //对于阅片人来讲,会有很多任务
|
||||||
|
// builder.HasMany(t => t.VisitTaskList).WithOne(t => t.DoctorUser).HasForeignKey(t => t.DoctorUserId).IsRequired(false);
|
||||||
builder.HasOne(t => t.SubjectVisit).WithMany(t => t.ReadModuleList).HasForeignKey(t => t.SubjectVisitId);
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,26 +12,31 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||||
|
|
||||||
public void Configure(EntityTypeBuilder<VisitTask> builder)
|
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.TaskInfluenceList).WithOne(s => s.OriginalTask).HasForeignKey(t => t.OriginalTaskId);
|
||||||
|
|
||||||
|
//对于全局任务而言,会关联多个全局访视阅片结果(因为同一全局会对多个访视的结果进行修改)
|
||||||
builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId);
|
builder.HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId);
|
||||||
|
//对于全局修改的任务而言,会关联多个全局访视阅片结果(因为同一个访视结果,会被多个全局修改)
|
||||||
|
|
||||||
|
//subject 删除了,但是任务没删除,导致的查询问题
|
||||||
builder.HasQueryFilter(b => b.Subject.IsDeleted == false);
|
builder.HasQueryFilter(b => b.Subject.IsDeleted == false);
|
||||||
|
|
||||||
|
|
||||||
|
//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 ReadingQuestionTrialConfigration : IEntityTypeConfiguration<ReadingQuestionTrial>
|
public class ReadingQuestionTrialConfigration : IEntityTypeConfiguration<ReadingQuestionTrial>
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<ReadingQuestionTrial> builder)
|
public void Configure(EntityTypeBuilder<ReadingQuestionTrial> builder)
|
||||||
{
|
{
|
||||||
|
//不影响之前的逻辑,附加评估
|
||||||
builder.HasQueryFilter(p => p.IsAdditional == false);
|
builder.HasQueryFilter(p => p.IsAdditional == false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,16 +46,11 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<SubjectUser> builder)
|
public void Configure(EntityTypeBuilder<SubjectUser> builder)
|
||||||
{
|
{
|
||||||
builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);
|
//对于替换后的医生而言,关联多个之前的医生
|
||||||
}
|
builder.HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.ReplacedSubjectUser);
|
||||||
}
|
|
||||||
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,4 +12,12 @@ https://www.cnblogs.com/cqpanda/p/16815263.html
|
||||||
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
|
dotnet ef migrations remove -p IRaCIS.Core.Test -c IRCContext
|
||||||
|
|
||||||
3、将迁移文件更新到数据库
|
3、将迁移文件更新到数据库
|
||||||
dotnet ef database update -p IRaCIS.Core.Test -c IRCContext
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,16 +18,5 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestOneConfigration : IEntityTypeConfiguration<TestOne>
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public void Configure(EntityTypeBuilder<TestOne> builder)
|
|
||||||
{
|
|
||||||
|
|
||||||
builder.HasOne(s => s.LatestTestMany).WithMany().HasForeignKey(t=>t.LatestTestManyId);
|
|
||||||
builder.HasOne(s => s.FinalTestMany).WithMany().HasForeignKey(t => t.FinalTestManyId);
|
|
||||||
builder.HasMany(s => s.TestManyList).WithOne(sv => sv.TestOne).HasForeignKey(t => t.TestOneId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ public partial class IRCContext : DbContext
|
||||||
public virtual DbSet<SubejectVisit> SubejectVisit { get; set; }
|
public virtual DbSet<SubejectVisit> SubejectVisit { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<Dictionary> Dictionary { get; set; }
|
public virtual DbSet<Dictionary> Dictionary { get; set; }
|
||||||
public virtual DbSet<TestOne> TestOne { get; set; }
|
public virtual DbSet<ReadingClinicalData> ReadingClinicalData { get; set; }
|
||||||
public virtual DbSet<TestMany> TestMany { get; set; }
|
public virtual DbSet<ReadModule> ReadModule { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
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");
|
=> optionsBuilder.UseSqlServer("Server=106.14.89.110,1433;Database=IRC_Code;User ID=sa;Password=mssql_KnTs2a;TrustServerCertificate=true");
|
||||||
|
|
|
@ -102,33 +102,30 @@ namespace IRaCIS.Core.Test.CodeFirstTest.MSSQL
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 一个外键 关联两个实体
|
||||||
public class TestOne : BaseFullAuditEntity
|
public class ReadingClinicalData : BaseFullAuditEntity
|
||||||
{
|
{
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(TestOne.FinalTestMany))]
|
|
||||||
public Guid? LatestTestManyId { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(TestOne.LatestTestMany))]
|
public Guid ReadingId { get; set; }
|
||||||
public Guid? FinalTestManyId { get; set; }
|
|
||||||
|
|
||||||
#region 同时配置一对多,一对一 导航属性
|
|
||||||
|
|
||||||
|
|
||||||
public TestMany FinalTestMany { get; set; }
|
[ForeignKey("ReadingId")]
|
||||||
|
|
||||||
public TestMany LatestTestMany { get; set; }
|
public SubejectVisit SubjectVisit { get; set; }
|
||||||
|
|
||||||
public List<TestMany> TestManyList { get; set; }
|
[ForeignKey("ReadingId")]
|
||||||
|
|
||||||
#endregion
|
public ReadModule ReadModule { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestMany : BaseFullAuditEntity
|
public class ReadModule : BaseFullAuditEntity
|
||||||
{
|
{
|
||||||
public TestOne TestOne { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public Guid TestOneId { get; set; }
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue