修改一版

Uat_Study
he 2022-05-06 13:40:06 +08:00
parent 503e3b7d01
commit 7a2c522ffd
2 changed files with 93 additions and 88 deletions

View File

@ -244,84 +244,14 @@ namespace IRaCIS.Application.Services
await _trialRepository.UpdatePartialNowNoQueryAsync(trialId, t => new Trial() { VisitPlanConfirmed = true });
//找到访视计划修改的Item
var changedList = await _visitStageRepository.Where(t => t.TrialId == trialId && t.IsConfirmed == false)
.Select(t => new
{
t.Trial.IsHaveFirstGiveMedicineDate,
t.Id,
t.VisitName,
t.TrialId,
t.VisitWindowLeft,
t.VisitWindowRight,
t.VisitDay,
t.VisitNum,
t.IsBaseLine,
t.BlindName,
t.Description,
IsConfirmed = true,
}).ToListAsync();
List<DataInspection> datas = new List<DataInspection>();
var createtime = DateTime.Now.AddSeconds(1);
changedList.ForEach(x =>
{
datas.Add(new DataInspection()
{
IsSign = false,
CreateTime = createtime,
//SubjectVisitName = x.VisitName,
VisitStageId = x.Id,
TrialId = x.TrialId,
JsonDetail = x.ToJcJson(),
Identification = "Confirm|Visit Plan Template|Data|Trial Setting-Visit Plan",
});
});
//foreach (var changedItem in changedList)
//{
// var list = await _subjectVisitRepository.Where(t => t.TrialId == trialId && t.VisitStageId == changedItem.Id).ToListAsync();
// list.ForEach(x =>
// {
// datas.Add(new DataInspection()
// {
// BlindName = x.BlindName,
// IsSign = false,
// SiteId = x.SiteId,
// SubjectId = x.SubjectId,
// SubjectVisitId = x.Id,
// CreateTime = createtime,
// SubjectVisitName = x.VisitName,
// TrialId = x.TrialId,
// Reason = "确认访视修改状态",
// JsonDetail = JsonConvert.SerializeObject(new
// {
// IsBaseLine = changedItem.IsBaseLine,
// VisitName = changedItem.VisitName,
// VisitNum = changedItem.VisitNum,
// VisitDay = changedItem.VisitDay,
// SubmitState = x.SubmitState,
// VisitWindowLeft = changedItem.VisitWindowLeft,
// VisitWindowRight = changedItem.VisitWindowRight
// }),
// Identification = "Edit|Visit|Info|Visit-Image Upload"
// });
// });
//}
var subjectsids = _repository.GetQueryable<Subject>().Where(x => x.TrialId == trialId).Select(x => new
{
x.Code,
@ -341,7 +271,28 @@ namespace IRaCIS.Application.Services
var addvisitStages = await _visitStageRepository.Where(x => !x.IsHaveFirstConfirmed && x.TrialId == trialId).ToListAsync();
addvisitStages.ForEach(x =>
{
subjectsids.ForEach(y =>
{
Guid guid = NewId.NextGuid();
SubjectVisit subjectVisit = new SubjectVisit()
{
SiteId = y.SiteId,
SubjectId = y.Id,
Id = guid,
VisitName = x.VisitName,
BlindName = x.BlindName,
IsBaseLine = x.IsBaseLine,
IsUrgent = false,
};
subjectVisits.Add(subjectVisit);
});
});
//await _subjectVisitRepository.AddRangeAsync()
await _repository.AddRangeAsync(subjectVisits);

View File

@ -73,8 +73,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
#endregion
#region 区分
// 项目人员
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(TrialUser)))
@ -88,9 +87,12 @@ namespace IRaCIS.Core.Infra.EFCore.Common
{
SubjectId = x.Id,
SubjectCode=x.Code,
},new
{
test="受试者"
});
}
// 访视
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit)))
{
@ -103,20 +105,36 @@ namespace IRaCIS.Core.Infra.EFCore.Common
SubjectVisitName=x.VisitName,
});
}
#endregion
// 访视计划
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(VisitStage)))
{
await InsertInspection<Subject>(item, type, x => new DataInspection()
{
VisitStageId = x.Id,
});
}
// 检查
foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy)))
{
await InsertInspection<Subject>(item, type, x => new DataInspection()
{
GeneralId = x.Id,
});
}
// 插入稽查信息
//async Task InsertInspectionData<T>(Expression<Func<T, DataInspection>> expression = null)
//foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy)))
//{
// await InsertInspection<T>(item, type, x => new DataInspection()
// await InsertInspection<Subject>(item, type, x => new DataInspection()
// {
// GeneralId = x.Id
// GeneralId = x.Id,
// });
//}
#endregion
}
/// <summary>
@ -127,7 +145,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// <param name="type">类型</param>
/// <param name="expression">表达式</param>
/// <returns></returns>
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> expression = null) where T:class
public async Task InsertInspection<T>(EntityEntry data, string type, Expression<Func<T, DataInspection>> expression = null,object otherItem=null) where T:class
{
DataInspection inspection = new DataInspection();
@ -144,7 +162,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
inspection.LastJsonDetail = originaldata.ToJcJson();
}
await AddInspectionRecordAsync(inspection, data.Entity);
await AddInspectionRecordAsync(inspection, data.Entity, otherItem);
}
@ -195,7 +213,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common
/// <param name="data">数据</param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
public async Task AddInspectionRecordAsync(DataInspection add, dynamic data)
public async Task AddInspectionRecordAsync(DataInspection add, dynamic data,object otherItem=null)
{
MapData(data, add);
InspectionGeneralData generalData = new InspectionGeneralData();
@ -233,9 +251,10 @@ namespace IRaCIS.Core.Infra.EFCore.Common
add.SignId = _userInfo.SignId;
add.IsSign = true;
}
var inspectionData = new InspectionData()
{
Data = data,
Data = AddJsonItem(data,otherItem),
Inspection = generalData
};
add.JsonDetail = inspectionData.ToJcJson();
@ -244,6 +263,41 @@ namespace IRaCIS.Core.Infra.EFCore.Common
}
/// <summary>
/// 往json里面添加属性
/// </summary>
/// <param name="json">json</param>
/// <param name="keyValues">字典</param>
/// <returns></returns>
public IDictionary<string, object> AddJsonItem(dynamic json, object otherItem=null)
{
var JsonData = JsonConvert.DeserializeObject<IDictionary<string, object>>((json as object).ToJcJson());
if (otherItem == null)
{
return JsonData;
}
var other = JsonConvert.DeserializeObject<IDictionary<string, object>>(otherItem.ToJcJson());
foreach (var item in other)
{
if (JsonData.ContainsKey(item.Key))
{
JsonData[item.Key] = item.Value;
}
else
{
JsonData.Add(item.Key, item.Value);
}
}
return JsonData;
}
/// <summary>
/// 判断是否为空
/// </summary>