Uat_Study
parent
35bbef3a69
commit
c2d17eb3df
|
@ -6,6 +6,7 @@ using IRaCIS.Core.Infrastructure;
|
|||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -184,40 +185,73 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
}
|
||||
|
||||
// 非Dicom文件
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
|
||||
//var noneDicomFile=
|
||||
|
||||
if (entitys.Any(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
|
||||
{
|
||||
var entity = item.Entity as NoneDicomStudyFile;
|
||||
var noneDicomStudy = entity.NoneDicomStudy;
|
||||
if (noneDicomStudy == null)
|
||||
var noneDicomStudyfile = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).Select(x => x.Entity).FirstOrDefault() as NoneDicomStudyFile;
|
||||
var noneDicomStudy = await _dbContext.NoneDicomStudy.Where(x => x.Id == noneDicomStudyfile.NoneDicomStudyId).FirstOrDefaultAsync();
|
||||
if (noneDicomStudy != null)
|
||||
{
|
||||
noneDicomStudy = await _dbContext.NoneDicomStudy.FirstOrDefaultAsync(x => x.Id == entity.NoneDicomStudyId);
|
||||
var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == noneDicomStudyfile.NoneDicomStudyId).CountAsync();
|
||||
var count = entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)).ToList().Count;
|
||||
if (type == "Deleted")
|
||||
{
|
||||
filecount = filecount - count;
|
||||
}
|
||||
noneDicomStudy = noneDicomStudy ?? new NoneDicomStudy();
|
||||
var fileCount = 0;
|
||||
if (type == "Add")
|
||||
else
|
||||
{
|
||||
fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() + 1;
|
||||
} else if (type == "Deleted")
|
||||
{
|
||||
fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() - 1;
|
||||
filecount = filecount + count;
|
||||
}
|
||||
await InsertInspection<NoneDicomStudyFile>(item, type, x => new DataInspection()
|
||||
|
||||
await InsertInspection<NoneDicomStudy>(null, type, x => new DataInspection()
|
||||
{
|
||||
GeneralId = x.Id,
|
||||
TrialId = noneDicomStudy.TrialId,
|
||||
SubjectId = noneDicomStudy.SubjectId,
|
||||
SiteId= noneDicomStudy.SiteId,
|
||||
SubjectVisitId = noneDicomStudy.SubjectVisitId,
|
||||
}, new
|
||||
{
|
||||
FileCount = filecount,
|
||||
}, noneDicomStudy);
|
||||
|
||||
},new {
|
||||
StudyCode = noneDicomStudy.StudyCode,
|
||||
Modality= noneDicomStudy.Modality,
|
||||
BodyPart= noneDicomStudy.BodyPart,
|
||||
FileCount= fileCount,
|
||||
ImageDate= noneDicomStudy.ImageDate,
|
||||
UpNum= 1,// 每次上传或下载一个
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
////非Dicom文件
|
||||
//foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile)))
|
||||
//{
|
||||
// var entity = item.Entity as NoneDicomStudyFile;
|
||||
// var noneDicomStudy = entity.NoneDicomStudy;
|
||||
// if (noneDicomStudy == null)
|
||||
// {
|
||||
// noneDicomStudy = await _dbContext.NoneDicomStudy.FirstOrDefaultAsync(x => x.Id == entity.NoneDicomStudyId);
|
||||
// }
|
||||
// noneDicomStudy = noneDicomStudy ?? new NoneDicomStudy();
|
||||
// var fileCount = 0;
|
||||
// if (type == "Add")
|
||||
// {
|
||||
// fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() + 1;
|
||||
// }
|
||||
// else if (type == "Deleted")
|
||||
// {
|
||||
// fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() - 1;
|
||||
// }
|
||||
// await InsertInspection<NoneDicomStudyFile>(item, type, x => new DataInspection()
|
||||
// {
|
||||
// GeneralId = x.Id,
|
||||
// TrialId = noneDicomStudy.TrialId,
|
||||
// SubjectId = noneDicomStudy.SubjectId,
|
||||
// SiteId = noneDicomStudy.SiteId,
|
||||
// SubjectVisitId = noneDicomStudy.SubjectVisitId,
|
||||
|
||||
// }, new
|
||||
// {
|
||||
// StudyCode = noneDicomStudy.StudyCode,
|
||||
// Modality = noneDicomStudy.Modality,
|
||||
// BodyPart = noneDicomStudy.BodyPart,
|
||||
// FileCount = fileCount,
|
||||
// ImageDate = noneDicomStudy.ImageDate,
|
||||
// UpNum = 1,// 每次上传或下载一个
|
||||
// });
|
||||
//}
|
||||
|
||||
// 访视
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit)))
|
||||
|
@ -357,8 +391,15 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
//Qc 问题答案
|
||||
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialQCQuestionAnswer)))
|
||||
{
|
||||
var entity = item.Entity as TrialQCQuestionAnswer;
|
||||
var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync();
|
||||
subjectvisit = subjectvisit ?? new SubjectVisit();
|
||||
type = type == "Update" ? "Add" : type;
|
||||
await InsertInspection<TrialQCQuestionAnswer>(item, type, x => new DataInspection()
|
||||
{
|
||||
SiteId= subjectvisit.SiteId,
|
||||
SubjectId= subjectvisit.SubjectId,
|
||||
SubjectVisitName= subjectvisit.VisitName,
|
||||
GeneralId = x.Id,
|
||||
});
|
||||
}
|
||||
|
@ -373,25 +414,30 @@ namespace IRaCIS.Core.Infra.EFCore.Common
|
|||
/// <param name="data">数据</param>
|
||||
/// <param name="type">类型</param>
|
||||
/// <param name="expression">表达式</param>
|
||||
/// <param name="entityData">实体对象</param>
|
||||
/// <returns></returns>
|
||||
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> expression = null,object otherItem=null) where T:class
|
||||
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> expression = null,object otherItem=null,T entityData=null) where T:class
|
||||
{
|
||||
|
||||
object entityobj = entityData == null ? data.Entity : entityData;
|
||||
DataInspection inspection = new DataInspection();
|
||||
if (expression != null)
|
||||
{
|
||||
var f = expression.Compile();
|
||||
var entity = data.Entity as T;
|
||||
var entity = entityobj as T;
|
||||
inspection = f(entity);
|
||||
}
|
||||
inspection.Identification = $"{_userInfo.RequestUrl}/{ data.Entity.GetType().Name}/{type}";
|
||||
inspection.Identification = $"{_userInfo.RequestUrl}/{ entityobj.GetType().Name}/{type}";
|
||||
if (data != null)
|
||||
{
|
||||
var originaldata = data.OriginalValues.ToObject();
|
||||
if (originaldata != null)
|
||||
{
|
||||
inspection.LastJsonDetail = originaldata.ToJcJson();
|
||||
}
|
||||
}
|
||||
|
||||
await AddInspectionRecordAsync(inspection, data.Entity, otherItem);
|
||||
|
||||
await AddInspectionRecordAsync(inspection, entityobj, otherItem);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue